Java Reference
In-Depth Information
<bean id="viewResolver" class="org.springframework.web.servlet.view.
å
XmlViewResolver" />
</beans>
InternalResourceViewResolver
If the application uses only JSPs, then maintaining an external view mapping configura-
tion is not necessary. The
InternalResourceViewResolver
class can determine the physical
view in the web application archive given the logical view name. Using this view resolver
is just a matter of configuration, as shown in Listing 3-15.
Listing 3-15.
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
>
<bean name="viewResolver" class="org.springframework.web.servlet.view.
å
InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view
å
.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean name="/policydetails.do" class="com.apress.insurance.web.controller
å
.PolicyDetailsController"/>
</beans>
Note that the
InternalResourceViewResolver
also returns
JstlView
. It inherits two
optional properties—prefix and suffix—from
UrlBasedViewResolver
to completely resolve
the physical resource. In this case, the view name
policydetails
will map to a physical
resource
/WEB-INF/jsp/policydetails.jps
. This view resolver can also be used with views
composed using the Apache Tiles layout framework.
