diff --git a/src/docs/asciidoc/web/webmvc-view.adoc b/src/docs/asciidoc/web/webmvc-view.adoc
index 401e752348..193bc55381 100644
--- a/src/docs/asciidoc/web/webmvc-view.adoc
+++ b/src/docs/asciidoc/web/webmvc-view.adoc
@@ -34,90 +34,6 @@ See http://www.thymeleaf.org/documentation.html[Thymeleaf+Spring] for more detai
-[[mvc-view-groovymarkup]]
-== Groovy Markup
-
-http://groovy-lang.org/templating.html#_the_markuptemplateengine[Groovy Markup Template Engine]
-is primarily aimed at generating XML-like markup (XML, XHTML, HTML5, etc) but that can
-be used to generate any text based content. The Spring Framework has a built-in
-integration for using Spring MVC with Groovy Markup.
-
-[TIP]
-====
-The Groovy Markup Tempalte engine requires Groovy 2.3.1+.
-====
-
-
-
-[[mvc-view-groovymarkup-configuration]]
-=== Configuration
-
-To configure the Groovy Markup Template Engine:
-
-[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;
- }
- }
-----
-
-To configure the same in XML:
-
-[source,xml,indent=0]
-[subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-----
-
-
-
-[[mvc-view-groovymarkup-example]]
-=== Example
-
-Unlike traditional template engines, Groovy Markup relies on a DSL that uses a builder
-syntax. Here is a sample template for an HTML page:
-
-[source,groovy,indent=0]
-[subs="verbatim,quotes"]
-----
- yieldUnescaped ''
- html(lang:'en') {
- head {
- meta('http-equiv':'"Content-Type" content="text/html; charset=utf-8"')
- title('My page')
- }
- body {
- p('This is an example of HTML contents')
- }
- }
-----
-
-
-
-
[[mvc-view-freemarker]]
== FreeMarker
@@ -542,6 +458,287 @@ In similar fashion, HTML escaping can be specified per field:
+[[mvc-view-groovymarkup]]
+== Groovy Markup
+
+http://groovy-lang.org/templating.html#_the_markuptemplateengine[Groovy Markup Template Engine]
+is primarily aimed at generating XML-like markup (XML, XHTML, HTML5, etc) but that can
+be used to generate any text based content. The Spring Framework has a built-in
+integration for using Spring MVC with Groovy Markup.
+
+[TIP]
+====
+The Groovy Markup Tempalte engine requires Groovy 2.3.1+.
+====
+
+
+
+[[mvc-view-groovymarkup-configuration]]
+=== Configuration
+
+To configure the Groovy Markup Template Engine:
+
+[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;
+ }
+ }
+----
+
+To configure the same in XML:
+
+[source,xml,indent=0]
+[subs="verbatim,quotes"]
+----
+
+
+
+
+
+
+
+
+----
+
+
+
+[[mvc-view-groovymarkup-example]]
+=== Example
+
+Unlike traditional template engines, Groovy Markup relies on a DSL that uses a builder
+syntax. Here is a sample template for an HTML page:
+
+[source,groovy,indent=0]
+[subs="verbatim,quotes"]
+----
+ yieldUnescaped ''
+ html(lang:'en') {
+ head {
+ meta('http-equiv':'"Content-Type" content="text/html; charset=utf-8"')
+ title('My page')
+ }
+ body {
+ p('This is an example of HTML contents')
+ }
+ }
+----
+
+
+
+
+[[mvc-view-script]]
+== Script Views
+
+The Spring Framework has a built-in integration for using Spring MVC with any
+templating library that can runs on top of the https://www.jcp
+.org/en/jsr/detail?id=223[JSR-223] Java scripting engine. Below is a list of
+templating libraries we've tested on different script engines:
+
+* http://handlebarsjs.com/[Handlebars] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
+* https://mustache.github.io/[Mustache] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
+* http://facebook.github.io/react/[React] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
+* http://www.embeddedjs.com/[EJS] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
+* http://www.stuartellis.eu/articles/erb/[ERB] running on http://jruby.org[JRuby]
+* https://docs.python.org/2/library/string.html#template-strings[String templates] running on http://www.jython.org/[Jython]
+
+[TIP]
+====
+The basic rule for a script engine is that it must implement the `ScriptEngine` and
+`Invocable` interfaces.
+====
+
+
+
+[[mvc-view-script-dependencies]]
+=== Requirements
+
+You need to have the script engine on your classpath:
+
+* http://openjdk.java.net/projects/nashorn/[Nashorn] JavaScript engine is provided with
+Java 8+. Using the latest update release available is highly recommended.
+* http://jruby.org[JRuby] should be added as a dependency for Ruby support.
+* http://www.jython.org[Jython] should be added as a dependency for Python support.
+
+You need to have the script templating library. One way to do that for Javascript is
+through http://www.webjars.org/[WebJars].
+
+
+
+[[mvc-view-script-integrate]]
+=== Script templates
+
+To be able to use script templates, you have to configure it in order to specify various parameters
+like the script engine to use, the script files to load and what function should be called to
+render the templates. This is done thanks to a
+
+Declare a `ScriptTemplateConfigurer` bean in order to specify the script engine to use,
+the script files to load, what function to call to render templates, and so on.
+Below is an exmaple with Mustache templates and the Nashorn JavaScript engine:
+
+[source,java,indent=0]
+[subs="verbatim,quotes"]
+----
+ @Configuration
+ @EnableWebMvc
+ public class MustacheConfig implements WebMvcConfigurer {
+
+ @Override
+ public void configureViewResolvers(ViewResolverRegistry registry) {
+ registry.scriptTemplate();
+ }
+
+ @Bean
+ public ScriptTemplateConfigurer configurer() {
+ ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
+ configurer.setEngineName("nashorn");
+ configurer.setScripts("mustache.js");
+ configurer.setRenderObject("Mustache");
+ configurer.setRenderFunction("render");
+ return configurer;
+ }
+ }
+----
+
+The same in XML:
+
+[source,xml,indent=0]
+[subs="verbatim,quotes"]
+----
+
+
+
+
+
+
+
+
+
+----
+
+The controller would look no different:
+
+[source,java,indent=0]
+[subs="verbatim,quotes"]
+----
+ @Controller
+ public class SampleController {
+
+ @GetMapping("/sample")
+ public String test(Model model) {
+ model.addObject("title", "Sample title");
+ model.addObject("body", "Sample body");
+ return "template";
+ }
+ }
+----
+
+And the Mustache template is:
+
+[source,html,indent=0]
+[subs="verbatim,quotes"]
+----
+
+
+ {{title}}
+
+
+ {{body}}
+
+
+----
+
+The render function is called with the following parameters:
+
+* `String template`: the template content
+* `Map model`: the view model
+* `String url`: the template url (since 4.2.2)
+
+`Mustache.render()` is natively compatible with this signature, so you can call it directly.
+
+If your templating technology requires some customization, you may provide a script that
+implements a custom render function. For example, http://handlebarsjs.com[Handlerbars]
+needs to compile templates before using them, and requires a
+http://en.wikipedia.org/wiki/Polyfill[polyfill] in order to emulate some
+browser facilities not available in the server-side script engine.
+
+[source,java,indent=0]
+[subs="verbatim,quotes"]
+----
+ @Configuration
+ @EnableWebMvc
+ public class MustacheConfig implements WebMvcConfigurer {
+
+ @Override
+ public void configureViewResolvers(ViewResolverRegistry registry) {
+ registry.scriptTemplate();
+ }
+
+ @Bean
+ public ScriptTemplateConfigurer configurer() {
+ ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
+ configurer.setEngineName("nashorn");
+ configurer.setScripts("polyfill.js", "handlebars.js", "render.js");
+ configurer.setRenderFunction("render");
+ configurer.setSharedEngine(false);
+ return configurer;
+ }
+ }
+----
+
+[NOTE]
+====
+Setting the `sharedEngine` property to `false` is required when using non thread-safe
+script engines with templating libraries not designed for concurrency, like Handlebars or
+React running on Nashorn for example. In that case, Java 8u60 or greater is required due
+to https://bugs.openjdk.java.net/browse/JDK-8076099[this bug].
+====
+
+`polyfill.js` only defines the `window` object needed by Handlebars to run properly:
+
+[source,javascript,indent=0]
+[subs="verbatim,quotes"]
+----
+ var window = {};
+----
+
+This basic `render.js` implementation compiles the template before using it. A production
+ready implementation should also store and reused cached templates / pre-compiled templates.
+This can be done on the script side, as well as any customization you need (managing
+template engine configuration for example).
+
+[source,javascript,indent=0]
+[subs="verbatim,quotes"]
+----
+ function render(template, model) {
+ var compiledTemplate = Handlebars.compile(template);
+ return compiledTemplate(model);
+ }
+----
+
+Check out Spring script templates unit tests
+(https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script[java],
+https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc/src/test/resources/org/springframework/web/servlet/view/script[resources])
+for more configuration examples.
+
+
+
+
[[mvc-view-jsp]]
== JSP & JSTL
@@ -1376,217 +1573,6 @@ is the default type.
-[[mvc-view-script]]
-== Script views
-
-The Spring Framework has a built-in integration for using Spring MVC with any
-templating library that can runs on top of the https://www.jcp
-.org/en/jsr/detail?id=223[JSR-223] Java scripting engine. Below is a list of
-templating libraries we've tested on different script engines:
-
-* http://handlebarsjs.com/[Handlebars] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
-* https://mustache.github.io/[Mustache] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
-* http://facebook.github.io/react/[React] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
-* http://www.embeddedjs.com/[EJS] running on http://openjdk.java.net/projects/nashorn/[Nashorn]
-* http://www.stuartellis.eu/articles/erb/[ERB] running on http://jruby.org[JRuby]
-* https://docs.python.org/2/library/string.html#template-strings[String templates] running on http://www.jython.org/[Jython]
-
-[TIP]
-====
-The basic rule for a script engine is that it must implement the `ScriptEngine` and
-`Invocable` interfaces.
-====
-
-
-
-[[mvc-view-script-dependencies]]
-=== Requirements
-
-You need to have the script engine on your classpath:
-
-* http://openjdk.java.net/projects/nashorn/[Nashorn] JavaScript engine is provided with
-Java 8+. Using the latest update release available is highly recommended.
-* http://jruby.org[JRuby] should be added as a dependency for Ruby support.
-* http://www.jython.org[Jython] should be added as a dependency for Python support.
-
-You need to have the script templating library. One way to do that for Javascript is
-through http://www.webjars.org/[WebJars].
-
-
-
-[[mvc-view-script-integrate]]
-=== Script templates
-
-To be able to use script templates, you have to configure it in order to specify various parameters
-like the script engine to use, the script files to load and what function should be called to
-render the templates. This is done thanks to a
-
-Declare a `ScriptTemplateConfigurer` bean in order to specify the script engine to use,
-the script files to load, what function to call to render templates, and so on.
-Below is an exmaple with Mustache templates and the Nashorn JavaScript engine:
-
-[source,java,indent=0]
-[subs="verbatim,quotes"]
-----
- @Configuration
- @EnableWebMvc
- public class MustacheConfig implements WebMvcConfigurer {
-
- @Override
- public void configureViewResolvers(ViewResolverRegistry registry) {
- registry.scriptTemplate();
- }
-
- @Bean
- public ScriptTemplateConfigurer configurer() {
- ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
- configurer.setEngineName("nashorn");
- configurer.setScripts("mustache.js");
- configurer.setRenderObject("Mustache");
- configurer.setRenderFunction("render");
- return configurer;
- }
- }
-----
-
-The same in XML:
-
-[source,xml,indent=0]
-[subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-
-----
-
-The controller would look no different:
-
-[source,java,indent=0]
-[subs="verbatim,quotes"]
-----
- @Controller
- public class SampleController {
-
- @GetMapping("/sample")
- public String test(Model model) {
- model.addObject("title", "Sample title");
- model.addObject("body", "Sample body");
- return "template";
- }
- }
-----
-
-And the Mustache template is:
-
-[source,html,indent=0]
-[subs="verbatim,quotes"]
-----
-
-
- {{title}}
-
-
- {{body}}
-
-
-----
-
-The render function is called with the following parameters:
-
-* `String template`: the template content
-* `Map model`: the view model
-* `String url`: the template url (since 4.2.2)
-
-`Mustache.render()` is natively compatible with this signature, so you can call it directly.
-
-If your templating technology requires some customization, you may provide a script that
-implements a custom render function. For example, http://handlebarsjs.com[Handlerbars]
-needs to compile templates before using them, and requires a
-http://en.wikipedia.org/wiki/Polyfill[polyfill] in order to emulate some
-browser facilities not available in the server-side script engine.
-
-[source,java,indent=0]
-[subs="verbatim,quotes"]
-----
- @Configuration
- @EnableWebMvc
- public class MustacheConfig implements WebMvcConfigurer {
-
- @Override
- public void configureViewResolvers(ViewResolverRegistry registry) {
- registry.scriptTemplate();
- }
-
- @Bean
- public ScriptTemplateConfigurer configurer() {
- ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
- configurer.setEngineName("nashorn");
- configurer.setScripts("polyfill.js", "handlebars.js", "render.js");
- configurer.setRenderFunction("render");
- configurer.setSharedEngine(false);
- return configurer;
- }
- }
-----
-
-[NOTE]
-====
-Setting the `sharedEngine` property to `false` is required when using non thread-safe
-script engines with templating libraries not designed for concurrency, like Handlebars or
-React running on Nashorn for example. In that case, Java 8u60 or greater is required due
-to https://bugs.openjdk.java.net/browse/JDK-8076099[this bug].
-====
-
-`polyfill.js` only defines the `window` object needed by Handlebars to run properly:
-
-[source,javascript,indent=0]
-[subs="verbatim,quotes"]
-----
- var window = {};
-----
-
-This basic `render.js` implementation compiles the template before using it. A production
-ready implementation should also store and reused cached templates / pre-compiled templates.
-This can be done on the script side, as well as any customization you need (managing
-template engine configuration for example).
-
-[source,javascript,indent=0]
-[subs="verbatim,quotes"]
-----
- function render(template, model) {
- var compiledTemplate = Handlebars.compile(template);
- return compiledTemplate(model);
- }
-----
-
-Check out Spring script templates unit tests
-(https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script[java],
-https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc/src/test/resources/org/springframework/web/servlet/view/script[resources])
-for more configuration examples.
-
-
-
-
-[[mvc-view-xml-marshalling]]
-== XML Marshalling
-
-The `MarshallingView` uses an XML `Marshaller` defined in the `org.springframework.oxm`
-package to render the response content as XML. The object to be marshalled can be set
-explicitly using ``MarhsallingView``'s `modelKey` bean property. Alternatively, the view
-will iterate over all model properties and marshal the first type that is supported
-by the `Marshaller`. For more information on the functionality in the
-`org.springframework.oxm` package refer to the chapter <>.
-
-
-
-
[[mvc-view-tiles]]
== Tiles
@@ -1764,161 +1750,73 @@ per preparer name (as used in your Tiles definitions).
-[[mvc-view-xslt]]
-== XSLT
+[[mvc-view-feeds]]
+== RSS, Atom
-XSLT is a transformation language for XML and is popular as a view technology within web
-applications. XSLT can be a good choice as a view technology if your application
-naturally deals with XML, or if your model can easily be converted to XML. The following
-section shows how to produce an XML document as model data and have it transformed with
-XSLT in a Spring Web MVC application.
+Both `AbstractAtomFeedView` and `AbstractRssFeedView` inherit from the base class
+`AbstractFeedView` and are used to provide Atom and RSS Feed views respectfully. They
+are based on java.net's https://rome.dev.java.net[ROME] project and are located in the
+package `org.springframework.web.servlet.view.feed`.
-This example is a trivial Spring application that creates a list of words in the
-`Controller` and adds them to the model map. The map is returned along with the view
-name of our XSLT view. See <> for details of Spring Web MVC's
-`Controller` interface. The XSLT Controller will turn the list of words into a simple XML
-document ready for transformation.
-
-
-
-[[mvc-view-xslt-beandefs]]
-=== Beans
-
-Configuration is standard for a simple Spring application.
-The MVC configuration has to define a `XsltViewResolver` bean and
-regular MVC annotation configuration.
+`AbstractAtomFeedView` requires you to implement the `buildFeedEntries()` method and
+optionally override the `buildFeedMetadata()` method (the default implementation is
+empty), as shown below.
[source,java,indent=0]
[subs="verbatim,quotes"]
----
-@EnableWebMvc
-@ComponentScan
-@Configuration
-public class WebConfig implements WebMvcConfigurer {
+ public class SampleContentAtomView extends AbstractAtomFeedView {
- @Bean
- public XsltViewResolver xsltViewResolver() {
- XsltViewResolver viewResolver = new XsltViewResolver();
- viewResolver.setPrefix("/WEB-INF/xsl/");
- viewResolver.setSuffix(".xslt");
- return viewResolver;
- }
+ @Override
+ protected void buildFeedMetadata(Map model,
+ Feed feed, HttpServletRequest request) {
+ // implementation omitted
+ }
-}
-----
-
-And we need a Controller that encapsulates our word generation logic.
-
-
-
-[[mvc-view-xslt-controllercode]]
-=== Controller
-
-The controller logic is encapsulated in a `@Controller` class, with the
-handler method being defined like so...
-
-[source,java,indent=0]
-[subs="verbatim,quotes"]
-----
- @Controller
- public class XsltController {
-
- @RequestMapping("/")
- public String home(Model model) throws Exception {
-
- Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- Element root = document.createElement("wordList");
-
- List words = Arrays.asList("Hello", "Spring", "Framework");
- for (String word : words) {
- Element wordNode = document.createElement("word");
- Text textNode = document.createTextNode(word);
- wordNode.appendChild(textNode);
- root.appendChild(wordNode);
- }
-
- model.addAttribute("wordList", root);
- return "home";
+ @Override
+ protected List buildFeedEntries(Map model,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // implementation omitted
}
}
----
-So far we've only created a DOM document and added it to the Model map. Note that you
-can also load an XML file as a `Resource` and use it instead of a custom DOM document.
+Similar requirements apply for implementing `AbstractRssFeedView`, as shown below.
-Of course, there are software packages available that will automatically 'domify'
-an object graph, but within Spring, you have complete flexibility to create the DOM
-from your model in any way you choose. This prevents the transformation of XML playing
-too great a part in the structure of your model data which is a danger when using tools
-to manage the domification process.
-
-Next, `XsltViewResolver` will resolve the "home" XSLT template file and merge the
-DOM document into it to generate our view.
-
-
-
-[[mvc-view-xslt-transforming]]
-=== Transformation
-
-Finally, the `XsltViewResolver` will resolve the "home" XSLT template file and merge the
-DOM document into it to generate our view. As shown in the `XsltViewResolver`
-configuration, XSLT templates live in the war file in the `'WEB-INF/xsl'` directory
-and end with a `"xslt"` file extension.
-
-[source,xml,indent=0]
+[source,java,indent=0]
[subs="verbatim,quotes"]
----
-
-
+ public class SampleContentAtomView extends AbstractRssFeedView {
-
+ @Override
+ protected void buildFeedMetadata(Map model,
+ Channel feed, HttpServletRequest request) {
+ // implementation omitted
+ }
-
-
- Hello!
-
- My First Words
-
-
-
-
+ @Override
+ protected List- buildFeedItems(Map model,
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
+ // implementation omitted
+ }
-
-
-
-
-
+ }
----
-This is rendered as:
+The `buildFeedItems()` and `buildFeedEntires()` methods pass in the HTTP request in case
+you need to access the Locale. The HTTP response is passed in only for the setting of
+cookies or other HTTP headers. The feed will automatically be written to the response
+object after the method returns.
-[source,html,indent=0]
-[subs="verbatim,quotes"]
-----
-
-
-
- Hello!
-
-
- My First Words
-
- - Hello
- - Spring
- - Framework
-
-
-
-----
+For an example of creating an Atom view please refer to Alef Arendsen's Spring Team Blog
+https://spring.io/blog/2009/03/16/adding-an-atom-view-to-an-application-using-spring-s-rest-support[entry].
[[mvc-view-document]]
-== Document views: PDF, Excel
+== PDF, Excel
@@ -2100,71 +1998,6 @@ document should appear listing each of the words in the model map.
-[[mvc-view-feeds]]
-== Feed views: RSS, Atom
-
-Both `AbstractAtomFeedView` and `AbstractRssFeedView` inherit from the base class
-`AbstractFeedView` and are used to provide Atom and RSS Feed views respectfully. They
-are based on java.net's https://rome.dev.java.net[ROME] project and are located in the
-package `org.springframework.web.servlet.view.feed`.
-
-`AbstractAtomFeedView` requires you to implement the `buildFeedEntries()` method and
-optionally override the `buildFeedMetadata()` method (the default implementation is
-empty), as shown below.
-
-[source,java,indent=0]
-[subs="verbatim,quotes"]
-----
- public class SampleContentAtomView extends AbstractAtomFeedView {
-
- @Override
- protected void buildFeedMetadata(Map model,
- Feed feed, HttpServletRequest request) {
- // implementation omitted
- }
-
- @Override
- protected List buildFeedEntries(Map model,
- HttpServletRequest request, HttpServletResponse response) throws Exception {
- // implementation omitted
- }
-
- }
-----
-
-Similar requirements apply for implementing `AbstractRssFeedView`, as shown below.
-
-[source,java,indent=0]
-[subs="verbatim,quotes"]
-----
- public class SampleContentAtomView extends AbstractRssFeedView {
-
- @Override
- protected void buildFeedMetadata(Map model,
- Channel feed, HttpServletRequest request) {
- // implementation omitted
- }
-
- @Override
- protected List- buildFeedItems(Map model,
- HttpServletRequest request, HttpServletResponse response) throws Exception {
- // implementation omitted
- }
-
- }
-----
-
-The `buildFeedItems()` and `buildFeedEntires()` methods pass in the HTTP request in case
-you need to access the Locale. The HTTP response is passed in only for the setting of
-cookies or other HTTP headers. The feed will automatically be written to the response
-object after the method returns.
-
-For an example of creating an Atom view please refer to Alef Arendsen's Spring Team Blog
-https://spring.io/blog/2009/03/16/adding-an-atom-view-to-an-application-using-spring-s-rest-support[entry].
-
-
-
-
[[mvc-view-jackson]]
== Jackson
@@ -2205,3 +2038,170 @@ XML mapping can be customized as needed through the use of JAXB or Jackson's pro
annotations. When further control is needed, a custom `XmlMapper` can be injected
through the `ObjectMapper` property for cases where custom XML
serializers/deserializers need to be provided for specific types.
+
+
+
+
+[[mvc-view-xml-marshalling]]
+== XML
+
+The `MarshallingView` uses an XML `Marshaller` defined in the `org.springframework.oxm`
+package to render the response content as XML. The object to be marshalled can be set
+explicitly using ``MarhsallingView``'s `modelKey` bean property. Alternatively, the view
+will iterate over all model properties and marshal the first type that is supported
+by the `Marshaller`. For more information on the functionality in the
+`org.springframework.oxm` package refer to the chapter <>.
+
+
+
+
+[[mvc-view-xslt]]
+== XSLT
+
+XSLT is a transformation language for XML and is popular as a view technology within web
+applications. XSLT can be a good choice as a view technology if your application
+naturally deals with XML, or if your model can easily be converted to XML. The following
+section shows how to produce an XML document as model data and have it transformed with
+XSLT in a Spring Web MVC application.
+
+This example is a trivial Spring application that creates a list of words in the
+`Controller` and adds them to the model map. The map is returned along with the view
+name of our XSLT view. See <> for details of Spring Web MVC's
+`Controller` interface. The XSLT Controller will turn the list of words into a simple XML
+document ready for transformation.
+
+
+
+[[mvc-view-xslt-beandefs]]
+=== Beans
+
+Configuration is standard for a simple Spring application.
+The MVC configuration has to define a `XsltViewResolver` bean and
+regular MVC annotation configuration.
+
+[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;
+ }
+
+}
+----
+
+And we need a Controller that encapsulates our word generation logic.
+
+
+
+[[mvc-view-xslt-controllercode]]
+=== Controller
+
+The controller logic is encapsulated in a `@Controller` class, with the
+handler method being defined like so...
+
+[source,java,indent=0]
+[subs="verbatim,quotes"]
+----
+ @Controller
+ public class XsltController {
+
+ @RequestMapping("/")
+ public String home(Model model) throws Exception {
+
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Element root = document.createElement("wordList");
+
+ List words = Arrays.asList("Hello", "Spring", "Framework");
+ for (String word : words) {
+ Element wordNode = document.createElement("word");
+ Text textNode = document.createTextNode(word);
+ wordNode.appendChild(textNode);
+ root.appendChild(wordNode);
+ }
+
+ model.addAttribute("wordList", root);
+ return "home";
+ }
+
+ }
+----
+
+So far we've only created a DOM document and added it to the Model map. Note that you
+can also load an XML file as a `Resource` and use it instead of a custom DOM document.
+
+Of course, there are software packages available that will automatically 'domify'
+an object graph, but within Spring, you have complete flexibility to create the DOM
+from your model in any way you choose. This prevents the transformation of XML playing
+too great a part in the structure of your model data which is a danger when using tools
+to manage the domification process.
+
+Next, `XsltViewResolver` will resolve the "home" XSLT template file and merge the
+DOM document into it to generate our view.
+
+
+
+[[mvc-view-xslt-transforming]]
+=== Transformation
+
+Finally, the `XsltViewResolver` will resolve the "home" XSLT template file and merge the
+DOM document into it to generate our view. As shown in the `XsltViewResolver`
+configuration, XSLT templates live in the war file in the `'WEB-INF/xsl'` directory
+and end with a `"xslt"` file extension.
+
+[source,xml,indent=0]
+[subs="verbatim,quotes"]
+----
+
+
+
+
+
+
+
+ Hello!
+
+
My First Words
+
+
+
+
+
+
+
+
+
+
+----
+
+This is rendered as:
+
+[source,html,indent=0]
+[subs="verbatim,quotes"]
+----
+
+
+
+ Hello!
+
+
+ My First Words
+
+ - Hello
+ - Spring
+ - Framework
+
+
+
+----
\ No newline at end of file
diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc
index aa740a3b47..9aff5be5b8 100644
--- a/src/docs/asciidoc/web/webmvc.adoc
+++ b/src/docs/asciidoc/web/webmvc.adoc
@@ -3760,6 +3760,11 @@ https://tools.ietf.org/html/rfc7232#section-2.3[RFC 7232 Section 2.3].
+include::webmvc-view.adoc[leveloffset=+1]
+
+
+
+
[[mvc-config]]
== MVC Config
[.small]#<>#
@@ -4578,10 +4583,6 @@ detected through a `` declaration.
-include::webmvc-view.adoc[leveloffset=+1]
-
-
-
[[mvc-http2]]
== HTTP/2
[.small]#<>#