官术网_书友最值得收藏!

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" value="/WEB-INF/jsp/" />
   <property name="suffix" value=".jsp" />
</bean>

Through the preceding bean definition in the web application context configuration, we instruct Spring MVC to create a bean for the InternalResourceViewResolver class (org.springframework.web.servlet.view.InternalResourceViewResolver). We will learn more about the view resolver in Chapter 5, Working with View Resolver.

主站蜘蛛池模板: 蓬安县| 都江堰市| 沛县| 河南省| 维西| 潮安县| 大名县| 玉环县| 壤塘县| 海宁市| 长武县| 兴安盟| 定远县| 隆林| 宝应县| 封丘县| 龙游县| 章丘市| 岗巴县| 凤翔县| 临武县| 柘荣县| 东源县| 马山县| 滨海县| 买车| 格尔木市| 南岸区| 抚州市| 信阳市| 秦皇岛市| 大石桥市| 海原县| 富锦市| 渭南市| 岳西县| 台东县| 南城县| 彰化市| 湖北省| 沙田区|