Java Reference
In-Depth Information
Listing 3-10. /WEB-INF/classes/insurance-views_fr_CA.properties
policydetails.class=org.springframework.web.servlet.view.JstlView
policydetails.url=/WEB-INF/jsp/PolicyDetails_fr_CA.jsp
The base resource bundle file is called views.properties . Depending on the locale,
the other resources will be named views_fr_CA.properties and so on. But this can be
changed by configuration. So when a view named policydetails is requested, the view
resolver creates a new instance of the JstlView class. This class represents a JSP-based
view that uses the JSP Standard Tag Library. The URL details are then passed to the
JstlView instance through setter injection. The logical view name is usually supplied by
the page controller, as shown in Listing 3-11.
Listing 3-11. PolicyDetailsController.java
public class PolicyDetailsController implements Controller {
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new ModelAndView("policydetails");
}
}
Finally, the page controller and view resolver should be configured in the Spring
application context so that the dispatcher servlet can use them. Listing 3-12 shows the
Spring configuration.
Listing 3-12. insurance-servlet.xml
<beans>
<bean name="/policydetails.do"
class="com.apress.insurance.web.controller.PolicyDetailsController"/>
<bean id="viewResolver" class="org.springframework.web.servlet. å
view.ResourceBundleViewResolver">
<property name="basename" value="insurance-views"></property>
</bean>
</beans>
 
Search WWH ::




Custom Search