diff --git a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-jsp.adoc b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-jsp.adoc index 6ca828bef563..920081c0b781 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-jsp.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-jsp.adoc @@ -9,19 +9,41 @@ The Spring Framework has a built-in integration for using Spring MVC with JSP an When developing with JSPs, you typically declare an `InternalResourceViewResolver` bean. -`InternalResourceViewResolver` can be used for dispatching to any Servlet resource but in -particular for JSPs. As a best practice, we strongly encourage placing your JSP files in -a directory under the `'WEB-INF'` directory so there can be no direct access by clients. +`InternalResourceViewResolver` can be used for dispatching to any Servlet resource but in particular for JSPs. +As a best practice, we strongly encourage placing your JSP files in a directory under the `WEB-INF` directory so there can be no direct access by clients. -[source,xml,indent=0,subs="verbatim,quotes"] +[source,java] ---- - - - - - +@EnableWebMvc +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Override + public void configureViewResolvers(ViewResolverRegistry registry) { + // Use sensible defaults + registry.jsp(); + // Example of customizing: + // registry.jsp("/WEB-INF/views/", ".jsp"); + } +} ---- +[NOTE] +==== +For legacy XML configuration: + +[source,xml] +---- + + + +---- + +Prefer JavaConfig for new applications. +==== + +[.text-muted] +See the Javadoc of ViewResolverRegistry#jsp() for default prefix and suffix values. [[mvc-view-jsp-jstl]] == JSPs versus JSTL