![]() |
ResourceBundleViewResolver in Spring MVC is used to resolve “view named” by view beans in the “.properties” file. View beans defined in the properties file are utilized by the ResourceBundleViewResolver to determine the view names. Using the Spring Web MVC Framework, the ResourceBundleViewResolver may be utilized as demonstrated in the following example. ResourceBundleViewResolver Configuration in Spring MVCResourceBundleViewResolver is a ViewResolver that uses a ResourceBundle property file for bean definitions. It is built with a bean and a base property file name set using setBasename(). This function performs internationalization and generates key-value pair values for view classes like JstlView and RedirectView. The default file name is viewed, but the base name can be changed using setBasename(). Resource Bundle Property FileLocate the property file. In this case, the data for two returned controller method values are being configured. result.(class)=org.springframework.web.servlet.view.JstlView Java Config for ResourceBundleViewResolver BeanTo define the ResourceBundleViewResolver bean, locate the Java configuration file: Java
Create ControllerLocate the class controller. Two methods are available here: one for testing JstlView and the other for RedirectView. Java
Create a JSP fileTo test JstlView, we are generating a JSP file. Java
Output:Now launch your Tomcat server and check if a regular browser can visit additional webpages from the webapps subdirectory. ConclusionIn this article, we learnt on the Java Spring MVC – ResourceBundleViewResolver Configuration. Using the view beans specified in the properties file, the ResourceBundleViewResolver resolves the view names. The ResourceBundleViewResolver may be utilized with the Spring Web MVC Framework. |
Reffered: https://www.geeksforgeeks.org
Advance Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |