Book Image

Spring MVC Beginner's Guide

By : Amuthan Ganeshan
Book Image

Spring MVC Beginner's Guide

By: Amuthan Ganeshan

Overview of this book

Table of Contents (19 chapters)
Spring MVC Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – understanding InternalResourceViewResolver


We instruct Spring to create a bean for an InternalResourceViewResolver class, but why? Who is going to use this bean? What is the role of the InternalResourceViewResolver bean in Spring MVC? Find the answer to these questions through the following exercise:

  1. Open DispatcherServlet-context.xml; you can find this file under the src/main/webapp/WEB-INF/spring/webcontext/ directory in your project.

  2. Change the prefix property value of the InternalResourceViewResolver bean as follows:

    <property name="prefix" value="/WEB-INF/views/" />
  3. Now, run your webstore project again and enter the URL http://localhost:8080/webstore/. You will see an HTTP Status 404 error message in your browser as shown in the following screenshot:

    An error page displaying the no resource found message

  4. Then, rename the jsp directory (/src/main/webapp/WEB-INF/jsp) to views.

  5. Finally, run your application and enter the URL, http://localhost:8080/webstore/. You will see...