How does InternalResourceViewResolver work in Spring MVC?

InternalResourceViewResolver is a Spring MVC ViewResolver implementation that resolves logical view names into JSP files by combining a configured prefix and suffix around the view name. It's the standard resolver for JSP-based applications.

Key Points

Example

With prefix /WEB-INF/views/ and suffix .jsp configured, a controller returning the view name "home" causes InternalResourceViewResolver to forward the request to /WEB-INF/views/home.jsp for rendering.

@Bean
public InternalResourceViewResolver viewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    return resolver;
}

Interview Tip

A concise interview answer is

InternalResourceViewResolver builds the actual JSP file path by wrapping a controller's logical view name with a configured prefix and suffix, then forwards the request to it. Pointing the prefix at /WEB-INF/ also keeps the raw JSP files from being requested directly by a browser.

Last updated: 11 November 2026

Previous question: Can you list different types of ViewResolvers used in Spring MVC?

Next question: What are the advantages of using a ContentNegotiatingViewResolver?

More Spring MVC (Optional) interview questions

All Spring MVC (Optional) questions