Friday, August 17, 2007

Spring: ResourceBundleViewResolver

When using ResourceBundleViewResolver, applicationContext.xml will contain following configuration.

<bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver" >
<property name="basename"><value>views</value></property>
</bean>


The “basename” property is used to tell ResourceBundleViewResolver how to construct
the names of the properties files that contain View definitions.

Sample views.properties file will look like as follows; It should reside in the classes folder of the server(..\WEB-INF\classes\).

pdfView.class=com.springinaction.training.mvc.BookListPdfView

home.class=org.springframework.web.servlet.view.JstlView
home.url=/WEB-INF/jsp/home.jsp
listBooks.class=org.springframework.web.servlet.view.JstlView
listBooks.url=/WEB-INF/jsp/listBooks.jsp
bookdetail.class=org.springframework.web.servlet.view.JstlView

bookdetail.url=/WEB-INF/jsp/bookdetail.jsp

No comments:

Post a Comment

Search