Spring MVC InternalResourceViewResolver

 

In Spring MVC, view resolvers allow us to render models in a browser, they provide a mapping between logical view name and the actual view.

InternalResourceViewResolver is used to resolve a logical view name to an internal resource view, most of time JSP page.

In this example, we will see how to use InternalResourceViewResolver to handle a logical view name and resolved it to the actual JSP page.

 

1.  Controller

File : ViewController

 

The method goToWelcome() returns the logical view name : welcome

 

2. Spring MVC Configuration

File : mvc-dispatcher-servlet.xml

 

The view name welcome will be resolved to  /WEB-INF/pages/welcome.jsp

 

3. Test It

URL : http://localhost:8080/SpringMVCInternalResourceViewResolver/hello.htm

SpringMVCInternalResourceViewResolver1

 

Download source code