diff --git a/framework-docs/framework-docs.gradle b/framework-docs/framework-docs.gradle
index 1ba931790dc..a18c727ad6a 100644
--- a/framework-docs/framework-docs.gradle
+++ b/framework-docs/framework-docs.gradle
@@ -80,9 +80,11 @@ dependencies {
implementation("javax.cache:cache-api")
implementation("org.apache.activemq:activemq-ra:6.1.2")
implementation("org.apache.commons:commons-dbcp2:2.11.0")
+ implementation("org.apache.groovy:groovy-templates")
implementation("org.aspectj:aspectjweaver")
implementation("org.assertj:assertj-core")
implementation("org.eclipse.jetty.websocket:jetty-websocket-jetty-api")
+ implementation("org.freemarker:freemarker")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
diff --git a/framework-docs/modules/ROOT/pages/web/webflux-view.adoc b/framework-docs/modules/ROOT/pages/web/webflux-view.adoc
index 17b165d5677..8d34f5072ed 100644
--- a/framework-docs/modules/ROOT/pages/web/webflux-view.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webflux-view.adoc
@@ -56,8 +56,7 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
@Configuration
- @EnableWebFlux
- public class WebConfig implements WebFluxConfigurer {
+ public class WebConfiguration implements WebFluxConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
@@ -80,8 +79,7 @@ Kotlin::
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@Configuration
- @EnableWebFlux
- class WebConfig : WebFluxConfigurer {
+ class WebConfiguration : WebFluxConfigurer {
override fun configureViewResolvers(registry: ViewResolverRegistry) {
registry.freeMarker()
@@ -119,8 +117,7 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
@Configuration
- @EnableWebFlux
- public class WebConfig implements WebFluxConfigurer {
+ public class WebConfiguration implements WebFluxConfigurer {
// ...
@@ -142,8 +139,7 @@ Kotlin::
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@Configuration
- @EnableWebFlux
- class WebConfig : WebFluxConfigurer {
+ class WebConfiguration : WebFluxConfigurer {
// ...
@@ -241,7 +237,7 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
@Configuration
- public class WebConfig implements WebFluxConfigurer {
+ public class WebConfiguration implements WebFluxConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
@@ -264,7 +260,7 @@ Kotlin::
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@Configuration
- class WebConfig : WebFluxConfigurer {
+ class WebConfiguration : WebFluxConfigurer {
override fun configureViewResolvers(registry: ViewResolverRegistry) {
registry.scriptTemplate()
diff --git a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-freemarker.adoc b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-freemarker.adoc
index f9c312d5251..6f7d1b3f746 100644
--- a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-freemarker.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-freemarker.adoc
@@ -14,82 +14,7 @@ integration for using Spring MVC with FreeMarker templates.
The following example shows how to configure FreeMarker as a view technology:
-[tabs]
-======
-Java::
-+
-[source,java,indent=0,subs="verbatim,quotes"]
-----
- @Configuration
- @EnableWebMvc
- public class WebConfig implements WebMvcConfigurer {
-
- @Override
- public void configureViewResolvers(ViewResolverRegistry registry) {
- registry.freeMarker();
- }
-
- // Configure FreeMarker...
-
- @Bean
- public FreeMarkerConfigurer freeMarkerConfigurer() {
- FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
- configurer.setTemplateLoaderPath("/WEB-INF/freemarker");
- configurer.setDefaultCharset(StandardCharsets.UTF_8);
- return configurer;
- }
- }
-----
-
-Kotlin::
-+
-[source,kotlin,indent=0,subs="verbatim,quotes"]
-----
- @Configuration
- @EnableWebMvc
- class WebConfig : WebMvcConfigurer {
-
- override fun configureViewResolvers(registry: ViewResolverRegistry) {
- registry.freeMarker()
- }
-
- // Configure FreeMarker...
-
- @Bean
- fun freeMarkerConfigurer() = FreeMarkerConfigurer().apply {
- setTemplateLoaderPath("/WEB-INF/freemarker")
- setDefaultCharset(StandardCharsets.UTF_8)
- }
- }
-----
-======
-
-The following example shows how to configure the same in XML:
-
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-
-
-----
-
-Alternatively, you can also declare the `FreeMarkerConfigurer` bean for full control over all
-properties, as the following example shows:
-
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-----
+include-code::./WebConfiguration[tag=snippet,indent=0]
Your templates need to be stored in the directory specified by the `FreeMarkerConfigurer`
shown in the preceding example. Given the preceding configuration, if your controller
@@ -107,19 +32,7 @@ properties on the `FreeMarkerConfigurer` bean. The `freemarkerSettings` property
a `java.util.Properties` object, and the `freemarkerVariables` property requires a
`java.util.Map`. The following example shows how to use a `FreeMarkerConfigurer`:
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-----
+include-code::./WebConfiguration[tag=snippet,indent=0]
See the FreeMarker documentation for details of settings and variables as they apply to
the `Configuration` object.
diff --git a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-groovymarkup.adoc b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-groovymarkup.adoc
index a15c3926137..d02af84b256 100644
--- a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-groovymarkup.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-groovymarkup.adoc
@@ -14,68 +14,7 @@ NOTE: The Groovy Markup Template engine requires Groovy 2.3.1+.
The following example shows how to configure the Groovy Markup Template Engine:
-[tabs]
-======
-Java::
-+
-[source,java,indent=0,subs="verbatim,quotes"]
-----
- @Configuration
- @EnableWebMvc
- public class WebConfig implements WebMvcConfigurer {
-
- @Override
- public void configureViewResolvers(ViewResolverRegistry registry) {
- registry.groovy();
- }
-
- // Configure the Groovy Markup Template Engine...
-
- @Bean
- public GroovyMarkupConfigurer groovyMarkupConfigurer() {
- GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
- configurer.setResourceLoaderPath("/WEB-INF/");
- return configurer;
- }
- }
-----
-
-Kotlin::
-+
-[source,kotlin,indent=0,subs="verbatim,quotes"]
-----
- @Configuration
- @EnableWebMvc
- class WebConfig : WebMvcConfigurer {
-
- override fun configureViewResolvers(registry: ViewResolverRegistry) {
- registry.groovy()
- }
-
- // Configure the Groovy Markup Template Engine...
-
- @Bean
- fun groovyMarkupConfigurer() = GroovyMarkupConfigurer().apply {
- resourceLoaderPath = "/WEB-INF/"
- }
- }
-----
-======
-
-The following example shows how to configure the same in XML:
-
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-----
-
+include-code::./WebConfiguration[tag=snippet,indent=0]
[[mvc-view-groovymarkup-example]]
== Example
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 7eb33c7180a..42348d86265 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
@@ -16,39 +16,11 @@ a directory under the `WEB-INF` directory so there can be no direct access by cl
This is what is done by the configuration below which registers a JSP view resolver using
a default view name prefix of `"/WEB-INF/"` and a default suffix of `".jsp"`.
-[tabs]
-======
-Java::
-+
-[source,java,indent=0,subs="verbatim,quotes"]
-----
-@EnableWebMvc
-@Configuration
-public class WebConfig implements WebMvcConfigurer {
-
- @Override
- public void configureViewResolvers(ViewResolverRegistry registry) {
- registry.jsp();
- }
-}
-----
-
-XML::
-+
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-
-----
-======
+include-code::./WebConfiguration[tag=snippet,indent=0]
[NOTE]
You can specify custom prefix and suffix.
-
[[mvc-view-jsp-jstl]]
== JSPs versus JSTL
diff --git a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-script.adoc b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-script.adoc
index 1db1c46cbe2..01657f79b55 100644
--- a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-script.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-script.adoc
@@ -36,66 +36,7 @@ You can declare a `ScriptTemplateConfigurer` bean to specify the script engine t
the script files to load, what function to call to render templates, and so on.
The following example uses the Jython Python engine:
-[tabs]
-======
-Java::
-+
-[source,java,indent=0,subs="verbatim,quotes"]
-----
- @Configuration
- public class WebConfig implements WebMvcConfigurer {
-
- @Override
- public void configureViewResolvers(ViewResolverRegistry registry) {
- registry.scriptTemplate();
- }
-
- @Bean
- public ScriptTemplateConfigurer configurer() {
- ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
- configurer.setEngineName("jython");
- configurer.setScripts("render.py");
- configurer.setRenderFunction("render");
- return configurer;
- }
- }
-----
-
-Kotlin::
-+
-[source,kotlin,indent=0,subs="verbatim,quotes"]
-----
- @Configuration
- class WebConfig : WebMvcConfigurer {
-
- override fun configureViewResolvers(registry: ViewResolverRegistry) {
- registry.scriptTemplate()
- }
-
- @Bean
- fun configurer() = ScriptTemplateConfigurer().apply {
- engineName = "jython"
- setScripts("render.py")
- renderFunction = "render"
- }
- }
-----
-
-XML::
-+
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-
-----
-======
+include-code::./WebConfiguration[tag=snippet,indent=0]
The render function is called with the following parameters:
diff --git a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-xslt.adoc b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-xslt.adoc
index 8a5ba00b8b1..8e8358335e8 100644
--- a/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-xslt.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-xslt.adoc
@@ -21,45 +21,7 @@ Configuration is standard for a simple Spring web application: The MVC configura
has to define an `XsltViewResolver` bean and regular MVC annotation configuration.
The following example shows how to do so:
-[tabs]
-======
-Java::
-+
-[source,java,indent=0,subs="verbatim,quotes"]
-----
- @EnableWebMvc
- @ComponentScan
- @Configuration
- public class WebConfig implements WebMvcConfigurer {
-
- @Bean
- public XsltViewResolver xsltViewResolver() {
- XsltViewResolver viewResolver = new XsltViewResolver();
- viewResolver.setPrefix("/WEB-INF/xsl/");
- viewResolver.setSuffix(".xslt");
- return viewResolver;
- }
- }
-----
-
-Kotlin::
-+
-[source,kotlin,indent=0,subs="verbatim,quotes"]
-----
- @EnableWebMvc
- @ComponentScan
- @Configuration
- class WebConfig : WebMvcConfigurer {
-
- @Bean
- fun xsltViewResolver() = XsltViewResolver().apply {
- setPrefix("/WEB-INF/xsl/")
- setSuffix(".xslt")
- }
- }
-----
-======
-
+include-code::./WebConfiguration[tag=snippet,indent=0]
[[mvc-view-xslt-controllercode]]
== Controller
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.java
new file mode 100644
index 00000000000..8ab63786a14
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewfreemarkercontextconfig;
+
+import java.nio.charset.StandardCharsets;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
+
+// tag::snippet[]
+@Configuration
+public class WebConfiguration implements WebMvcConfigurer {
+
+ @Override
+ public void configureViewResolvers(ViewResolverRegistry registry) {
+ registry.freeMarker();
+ }
+
+ // Configure FreeMarker...
+
+ @Bean
+ public FreeMarkerConfigurer freeMarkerConfigurer() {
+ FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
+ configurer.setTemplateLoaderPath("/WEB-INF/freemarker");
+ configurer.setDefaultCharset(StandardCharsets.UTF_8);
+ return configurer;
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.java
new file mode 100644
index 00000000000..62132848177
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewgroovymarkupconfiguration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer;
+
+// tag::snippet[]
+@Configuration
+public class WebConfiguration implements WebMvcConfigurer {
+
+ @Override
+ public void configureViewResolvers(ViewResolverRegistry registry) {
+ registry.groovy();
+ }
+
+ // Configure the Groovy Markup Template Engine...
+
+ @Bean
+ public GroovyMarkupConfigurer groovyMarkupConfigurer() {
+ GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
+ configurer.setResourceLoaderPath("/WEB-INF/");
+ return configurer;
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.java
new file mode 100644
index 00000000000..fbc7d128641
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewjspresolver;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+// tag::snippet[]
+@Configuration
+public class WebConfiguration implements WebMvcConfigurer {
+
+ @Override
+ public void configureViewResolvers(ViewResolverRegistry registry) {
+ registry.jsp();
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.java
new file mode 100644
index 00000000000..1c3146fc098
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewscriptintegrate;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.view.script.ScriptTemplateConfigurer;
+
+// tag::snippet[]
+@Configuration
+public class WebConfiguration implements WebMvcConfigurer {
+
+ @Override
+ public void configureViewResolvers(ViewResolverRegistry registry) {
+ registry.scriptTemplate();
+ }
+
+ @Bean
+ public ScriptTemplateConfigurer configurer() {
+ ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
+ configurer.setEngineName("jython");
+ configurer.setScripts("render.py");
+ configurer.setRenderFunction("render");
+ return configurer;
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.java
new file mode 100644
index 00000000000..38fdf3afd6a
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewsfreemarker;
+
+import java.util.Map;
+
+import freemarker.template.utility.XmlEscape;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
+
+@Configuration
+public class WebConfiguration {
+
+ // tag::snippet[]
+ @Bean
+ public FreeMarkerConfigurer freeMarkerConfigurer() {
+ FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
+ configurer.setTemplateLoaderPath("/WEB-INF/freemarker");
+ configurer.setFreemarkerVariables(Map.of("xml_escape", new XmlEscape()));
+ return configurer;
+ }
+ // end::snippet[]
+}
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewxsltbeandefs/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewxsltbeandefs/WebConfiguration.java
new file mode 100644
index 00000000000..9e2a47b263d
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvcview/mvcviewxsltbeandefs/WebConfiguration.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewxsltbeandefs;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.view.xslt.XsltViewResolver;
+
+// tag::snippet[]
+@Configuration
+public class WebConfiguration implements WebMvcConfigurer {
+
+ @Bean
+ public XsltViewResolver xsltViewResolver() {
+ XsltViewResolver viewResolver = new XsltViewResolver();
+ viewResolver.setPrefix("/WEB-INF/xsl/");
+ viewResolver.setSuffix(".xslt");
+ return viewResolver;
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.kt
new file mode 100644
index 00000000000..96728a34421
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewfreemarkercontextconfig
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
+import java.nio.charset.StandardCharsets
+
+// tag::snippet[]
+@Configuration
+class WebConfiguration : WebMvcConfigurer {
+
+ override fun configureViewResolvers(registry: ViewResolverRegistry) {
+ registry.freeMarker()
+ }
+
+ // Configure FreeMarker...
+
+ @Bean
+ fun freeMarkerConfigurer() = FreeMarkerConfigurer().apply {
+ setTemplateLoaderPath("/WEB-INF/freemarker")
+ setDefaultCharset(StandardCharsets.UTF_8)
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.kt
new file mode 100644
index 00000000000..5e990aafbfb
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewgroovymarkupconfiguration
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
+import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer
+
+// tag::snippet[]
+@Configuration
+class WebConfiguration : WebMvcConfigurer {
+
+ override fun configureViewResolvers(registry: ViewResolverRegistry) {
+ registry.groovy()
+ }
+
+ // Configure the Groovy Markup Template Engine...
+
+ @Bean
+ fun groovyMarkupConfigurer() = GroovyMarkupConfigurer().apply {
+ resourceLoaderPath = "/WEB-INF/"
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.kt
new file mode 100644
index 00000000000..0fd338e3c92
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewjspresolver
+
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
+
+// tag::snippet[]
+@Configuration
+class WebConfiguration : WebMvcConfigurer {
+
+ override fun configureViewResolvers(registry: ViewResolverRegistry) {
+ registry.jsp()
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.kt
new file mode 100644
index 00000000000..42c2309d122
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewscriptintegrate
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
+import org.springframework.web.servlet.view.script.ScriptTemplateConfigurer
+
+// tag::snippet[]
+@Configuration
+class WebConfiguration : WebMvcConfigurer {
+
+ override fun configureViewResolvers(registry: ViewResolverRegistry) {
+ registry.scriptTemplate()
+ }
+
+ @Bean
+ fun configurer() = ScriptTemplateConfigurer().apply {
+ engineName = "jython"
+ setScripts("render.py")
+ renderFunction = "render"
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.kt
new file mode 100644
index 00000000000..e41dd27b68e
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewsfreemarker
+
+import freemarker.template.utility.XmlEscape
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
+
+@Configuration
+class WebConfiguration {
+
+ // tag::snippet[]
+ @Bean
+ fun freeMarkerConfigurer() = FreeMarkerConfigurer().apply {
+ setTemplateLoaderPath("/WEB-INF/freemarker")
+ setFreemarkerVariables(mapOf("xml_escape" to XmlEscape()))
+ }
+ // end::snippet[]
+}
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewxsltbeandefs/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewxsltbeandefs/WebConfiguration.kt
new file mode 100644
index 00000000000..57d4dc65af3
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvcview/mvcviewxsltbeandefs/WebConfiguration.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvcview.mvcviewxsltbeandefs
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
+import org.springframework.web.servlet.view.xslt.XsltViewResolver
+
+// tag::snippet[]
+@Configuration
+class WebConfiguration : WebMvcConfigurer {
+
+ @Bean
+ fun xsltViewResolver() = XsltViewResolver().apply {
+ setPrefix("/WEB-INF/xsl/")
+ setSuffix(".xslt")
+ }
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.xml
new file mode 100644
index 00000000000..6b0c42cb053
--- /dev/null
+++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewfreemarkercontextconfig/WebConfiguration.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.xml
new file mode 100644
index 00000000000..50a9d3f03c3
--- /dev/null
+++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewgroovymarkupconfiguration/WebConfiguration.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.xml
new file mode 100644
index 00000000000..be42ac149d6
--- /dev/null
+++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewjspresolver/WebConfiguration.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.xml
new file mode 100644
index 00000000000..a2e003a7bbc
--- /dev/null
+++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewscriptintegrate/WebConfiguration.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.xml
new file mode 100644
index 00000000000..09ab5fb3e0f
--- /dev/null
+++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvcview/mvcviewsfreemarker/WebConfiguration.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file