Spring MVC ResourceBundleViewResolver tutorial with example


ResourceBundleViewResolver

A ViewResolver implementation that uses bean definitions in a ResourceBundle, specified by the bundle basename.

The bundle is typically defined in a properties file, located in the classpath. The default bundle basename is "views".


This ViewResolver supports localized view definitions, using the default support of PropertyResourceBundle. For example, the basename "views" will be resolved as class path resources "views_de_AT.properties", "views_de.properties", "views.properties" - for a given Locale "de_AT".


Example
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
           http://www.springframework.org/schema/util 
           http://www.springframework.org/schema/util/spring-util-3.0.xsd  
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
    <!-- ************************************************************* --> 
      
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
	<property name="basename" value="dispatcher-view"/>
</bean>

<!-- ************************************************************* --> 

<bean name="/resourceBundleViewResolver.htm" class="com.candidjava.springmvc.ResourceBundleViewResolver"/>

	<!-- ************************************************************* -->
	
</beans>

dispatcher-view.properties
page.(class)=org.springframework.web.servlet.view.JstlView
page.url=/WEB-INF/pages/page.jsp

Screenshot
            
            
                        

Download
            ResourceBundleViewResolver maven zip
            ResourceBundleViewResolver war



Comments


©candidjava.com