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

View resolvers


We saw the purpose of the first two tags that are specified within the web application context configuration file:

<mvc:annotation-driven />
<context:component-scan base-package="com.packt.webstore" />

Based on these tags, Spring creates the necessary beans to handle a web request and also creates beans for all the @Controller classes. However, to run a Spring MVC application successfully, Spring needs one more bean; this bean is called a view resolver.

A view resolver helps the dispatcher servlet identify the views that have to be rendered as the response for a specific web request. Spring MVC provides various view resolver implementations to identify views, and InternalResourceViewResolver is one such implementation. The final tag in the web application context configuration is the bean definition for the InternalResourceViewResolver class as follows:

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix...