@ -149,7 +149,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
@@ -149,7 +149,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
@ -22,8 +22,8 @@ extensive set of features that will make such a transition easier. Thymeleaf is
@@ -22,8 +22,8 @@ extensive set of features that will make such a transition easier. Thymeleaf is
developed and maintained. For a more complete introduction see the
http://www.thymeleaf.org/[Thymeleaf] project home page.
The Thymeleaf integration with Spring MVC is managed by the Thymeleaf project. The
configuration involves a few bean declarations such as
The Thymeleaf integration with Spring MVC is managed by the Thymeleaf project.
The configuration involves a few bean declarations such as
`ServletContextTemplateResolver`, `SpringTemplateEngine`, and `ThymeleafViewResolver`.
See http://www.thymeleaf.org/documentation.html[Thymeleaf+Spring] for more details.
@ -941,9 +941,8 @@ The preceding JSP assumes that the variable name of the form backing object is
@@ -941,9 +941,8 @@ The preceding JSP assumes that the variable name of the form backing object is
==== The input tag
This tag renders an HTML 'input' tag using the bound value and type='text' by default.
For an example of this tag, see <<mvc-view-jsp-formtaglib-formtag>>. Starting with Spring
3.1 you can use other types such HTML5-specific types like 'email', 'tel', 'date', and
others.
For an example of this tag, see <<mvc-view-jsp-formtaglib-formtag>>. You may also use
HTML5-specific types like 'email', 'tel', 'date', and others.
[[mvc-view-jsp-formtaglib-checkboxtag]]
@ -1563,12 +1562,12 @@ The corresponding `@Controller` method is shown below:
@@ -1563,12 +1562,12 @@ The corresponding `@Controller` method is shown below:
[[mvc-view-jsp-formtaglib-html5]]
==== HTML5 tags
Starting with Spring 3, the Spring form tag library allows entering dynamic attributes,
which means you can enter any HTML5 specific attributes.
The Spring form tag library allows entering dynamic attributes, which means you can
enter any HTML5 specific attributes.
In Spring 3.1, the form input tag supports entering a type attribute other than 'text'.
This is intended to allow rendering new HTML5 specific input types such as 'email',
'date', 'range', and others. Note that entering type='text' is not required since 'text'
The form input tag supports entering a type attribute other than 'text'. This is
intended to allow rendering new HTML5 specific input types such as 'email', 'date',
'range', and others. Note that entering type='text' is not required since 'text'
is the default type.
@ -1801,7 +1800,6 @@ Similar requirements apply for implementing `AbstractRssFeedView`, as shown belo
@@ -1801,7 +1800,6 @@ Similar requirements apply for implementing `AbstractRssFeedView`, as shown belo
`org.springframework.web.servlet.view.document.AbstractXlsView` is provided as a base
class for Excel views based on POI, with specialized subclasses `AbstractXlsxView`
and `AbstractXlsxStreamingView`, superseding the outdated `AbstractExcelView` class.
Once again, amend the controller to return the `pdf` view with `return new
ModelAndView("pdf", map);`, and reload the URL in your application. This time a PDF
document should appear listing each of the words in the model map.
The programming model is similar to `AbstractPdfView`, with `buildExcelDocument()`
as the central template method and controllers being able to return such a view from
an external definition (by name) or as a `View` instance from the handler method.
@ -2014,16 +1891,16 @@ document should appear listing each of the words in the model map.
@@ -2014,16 +1891,16 @@ document should appear listing each of the words in the model map.
[[mvc-view-json-mapping]]
=== JSON
=== Jackson-based JSON views
[.small]#<<web-reactive.adoc#webflux-view-httpmessagewriter,Same in Spring WebFlux>>#
The `MappingJackson2JsonView` uses the Jackson library's `ObjectMapper` to render the response
content as JSON. By default, the entire contents of the model map (with the exception of
framework-specific classes) will be encoded as JSON. For cases where the contents of the
map need to be filtered, users may specify a specific set of model attributes to encode
via the `RenderedAttributes` property. The `extractValueFromSingleKeyModel` property may
also be used to have the value in single-key models extracted and serialized directly
rather than as a map of model attributes.
via the `modelKeys` property. The `extractValueFromSingleKeyModel` property may also be
used to have the value in single-key models extracted and serialized directly rather than
as a map of model attributes.
JSON mapping can be customized as needed through the use of Jackson's provided
annotations. When further control is needed, a custom `ObjectMapper` can be injected
@ -2033,7 +1910,7 @@ serializers/deserializers need to be provided for specific types.
@@ -2033,7 +1910,7 @@ serializers/deserializers need to be provided for specific types.
[[mvc-view-xml-mapping]]
=== XML
=== Jackson-based XML views
[.small]#<<web-reactive.adoc#webflux-view-httpmessagewriter,Same in Spring WebFlux>>#
The `MappingJackson2XmlView` uses the
@ -2051,11 +1928,11 @@ serializers/deserializers need to be provided for specific types.
@@ -2051,11 +1928,11 @@ serializers/deserializers need to be provided for specific types.
[[mvc-view-xml-marshalling]]
== XML
== 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
explicitly using ``MarshallingView``'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
@ -2065,7 +1942,7 @@ by the `Marshaller`. For more information on the functionality in the
@@ -2065,7 +1942,7 @@ by the `Marshaller`. For more information on the functionality in the
[[mvc-view-xslt]]
== XSLT
== XSLT views
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
@ -2084,9 +1961,8 @@ document ready for transformation.
@@ -2084,9 +1961,8 @@ 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.
Configuration is standard for a simple Spring web application: The MVC configuration
has to define an `XsltViewResolver` bean and regular MVC annotation configuration.
[source,java,indent=0]
[subs="verbatim,quotes"]
@ -2103,7 +1979,6 @@ public class WebConfig implements WebMvcConfigurer {
@@ -2103,7 +1979,6 @@ public class WebConfig implements WebMvcConfigurer {
viewResolver.setSuffix(".xslt");
return viewResolver;
}
}
----
@ -2115,7 +1990,7 @@ And we need a Controller that encapsulates our word generation logic.
@@ -2115,7 +1990,7 @@ And we need a Controller that encapsulates our word generation logic.
=== Controller
The controller logic is encapsulated in a `@Controller` class, with the
handler method being defined like so...
handler method being defined as follows:
[source,java,indent=0]
[subs="verbatim,quotes"]
@ -2125,7 +2000,6 @@ handler method being defined like so...
@@ -2125,7 +2000,6 @@ handler method being defined like so...
@RequestMapping("/")
public String home(Model model) throws Exception {