Spring MVC ResourceBundle View Resolver

Spring MVC ResourceBundle View Resolver is used to resolve views based on the entries in to a specified properties file. The property file name is to be specified while configuring the org.springframework.web.servlet.view.ResourceBundleViewResolver bean in the dispatcher servlet.
If no property file name is given, then ResourceBundleViewResolver loads the views from the default property file – views.property from the project classpath.

If the ResourceBundleViewResolver is unable to find any valid view from any of the property files, Or if it is unable to find the property file itself then we may get the following exception

Lets see an example of Spring MVC ResourceBundle View Resolver

1. dispatcher servlet configuration

We are using the properties file my-views.properties, so we have defined it in the ResourceBundleViewResolver

2. my-views.properties

The things to remember while creating the properties file are
1. Name of the View – home
2. Type of the View – .class
3. URL of the View – .url

3. Controller

4. home.jsp


When view name home is returned by controller, the ResourceBundleViewResolver will find the key starting with home in my-views.properties file, and return the view that is defined in home.url i.e. /WEB-INF/jsp/home.jsp

Features of Spring MVC | Spring MVC ResourceBundle View Resolver

Download Full Code – SpringMVC-ResourceBundleViewResolver.zip