Java Reference
In-Depth Information
To use an XML-based view resolver, configuration information should be moved in
XML files from the properties file. This view configuration file should be located in the
WEB-INF folder and is called views.xml by default. As with most parameters in Spring, the
location too is configurable. Listing 3-13 shows the views.xml file.
Listing 3-13. /WEB-INF/views.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
>
<bean name="policydetails" class="org.springframework.web. å
servlet.view.JstlView">
<property name="url" value="/WEB-INF/jsp/PolicyDetails.jsp" />
</bean>
</beans>
Notice that the configuration used is quite similar to the application context configu-
ration. The beans defined in views.xml are in fact an extension of the main application
context factory. Finally, we need to configure the XmlViewResolver in the application con-
text so that it can be used by the front controller servlet. Listing 3-14 shows the modified
application context configuration.
Listing 3-14. insurance-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
>
<bean name="/policydetails.do" class="com.apress.insurance.web.controller. å
PolicyDetailsController"/>
 
Search WWH ::




Custom Search