@@ -27,7 +27,7 @@ documentation section for more details.
27
27
28
28
29
29
[[mvc-view-groovymarkup]]
30
- == Groovy Markup Templates
30
+ == Groovy Markup
31
31
32
32
The http://groovy-lang.org/templating.html#_the_markuptemplateengine[Groovy Markup Template Engine]
33
33
is another view technology, supported by Spring. This template engine is a template engine primarily
@@ -157,7 +157,7 @@ for JSP's. So if your controller returns a ModelAndView object containing a view
157
157
158
158
159
159
[[mvc-views-freemarker]]
160
- === Advanced FreeMarker configuration
160
+ === Advanced config
161
161
FreeMarker 'Settings' and 'SharedVariables' can be passed directly to the FreeMarker
162
162
`Configuration` object managed by Spring by setting the appropriate bean properties on
163
163
the `FreeMarkerConfigurer` bean. The `freemarkerSettings` property requires a
@@ -185,7 +185,7 @@ the `Configuration` object.
185
185
186
186
187
187
[[mvc-view-freemarker-forms]]
188
- === Bind support and form handling
188
+ === Form handling
189
189
Spring provides a tag library for use in JSP's that contains (amongst other things) a
190
190
`<spring:bind/>` tag. This tag primarily enables forms to display values from form
191
191
backing objects and to show the results of failed validations from a `Validator` in the
@@ -251,7 +251,7 @@ They are explained in the next section.
251
251
252
252
253
253
[[mvc-views-form-macros]]
254
- ==== Form input generation macros
254
+ ==== Input macros
255
255
Additional convenience macros for both languages simplify both binding and form
256
256
generation (including validation error display). It is never necessary to use these
257
257
macros to generate form input fields, and they can be mixed and matched with simple HTML
@@ -456,7 +456,7 @@ user still sees the more user friendly city names.
456
456
457
457
458
458
[[mvc-views-form-macros-html-escaping]]
459
- ==== HTML escaping and XHTML compliance
459
+ ==== HTML escaping
460
460
Default usage of the form macros above will result in HTML tags that are HTML 4.01
461
461
compliant and that use the default value for HTML escaping defined in your web.xml as
462
462
used by Spring's bind support. In order to make the tags XHTML compliant or to override
@@ -560,15 +560,15 @@ under the `'WEB-INF'` directory, so there can be no direct access by clients.
560
560
561
561
562
562
[[mvc-view-jsp-jstl]]
563
- === 'Plain-old' JSPs versus JSTL
563
+ === JSPs versus JSTL
564
564
When using the Java Standard Tag Library you must use a special view class, the
565
565
`JstlView`, as JSTL needs some preparation before things such as the I18N features will
566
566
work.
567
567
568
568
569
569
570
570
[[mvc-view-jsp-tags]]
571
- === Additional tags facilitating development
571
+ === Spring tags
572
572
Spring provides data binding of request parameters to command objects as described in
573
573
earlier chapters. To facilitate the development of JSP pages in combination with those
574
574
data binding features, Spring provides a few tags that make things even easier. All
@@ -581,7 +581,7 @@ or see the tag library description.
581
581
582
582
583
583
[[mvc-view-jsp-formtaglib]]
584
- === Using Spring's form tag library
584
+ === Spring form tags
585
585
As of version 2.0, Spring provides a comprehensive set of data binding-aware tags for
586
586
handling form elements when using JSP and Spring Web MVC. Each tag provides support for
587
587
the set of attributes of its corresponding HTML tag counterpart, making the tags
@@ -1338,7 +1338,7 @@ is the default type.
1338
1338
1339
1339
1340
1340
[[mvc-view-script]]
1341
- == Script templates
1341
+ == Script views
1342
1342
1343
1343
It is possible to integrate any templating library running on top of a JSR-223
1344
1344
script engine in web applications using Spring. The following describes in a
@@ -1355,7 +1355,7 @@ It has been tested with:
1355
1355
* https://docs.python.org/2/library/string.html#template-strings[String templates] running on http://www.jython.org/[Jython]
1356
1356
1357
1357
[[mvc-view-script-dependencies]]
1358
- === Dependencies
1358
+ === Requirements
1359
1359
1360
1360
To be able to use script templates integration, you need to have available in your classpath
1361
1361
the script engine:
@@ -1375,7 +1375,7 @@ in order to make your javascript libraries available in the classpath.
1375
1375
1376
1376
1377
1377
[[mvc-view-script-integrate]]
1378
- === How to integrate script based templating
1378
+ === Script templates
1379
1379
1380
1380
To be able to use script templates, you have to configure it in order to specify various parameters
1381
1381
like the script engine to use, the script files to load and what function should be called to
@@ -1535,7 +1535,7 @@ for more configuration examples.
1535
1535
1536
1536
1537
1537
[[mvc-view-xml-marshalling]]
1538
- == XML Marshalling View
1538
+ == XML Marshalling
1539
1539
The `MarshallingView` uses an XML `Marshaller` defined in the `org.springframework.oxm`
1540
1540
package to render the response content as XML. The object to be marshalled can be set
1541
1541
explicitly using `MarhsallingView`'s `modelKey` bean property. Alternatively, the view
@@ -1569,7 +1569,7 @@ to your project.
1569
1569
1570
1570
1571
1571
[[mvc-view-tiles-integrate]]
1572
- === How to integrate Tiles
1572
+ === Configuration
1573
1573
To be able to use Tiles, you have to configure it using files containing definitions
1574
1574
(for basic information on definitions and other Tiles concepts, please have a look at
1575
1575
http://tiles.apache.org[]). In Spring this is done using the `TilesConfigurer`. Have a
@@ -1626,7 +1626,7 @@ them otherwise in the file names for Tiles definitions.
1626
1626
1627
1627
1628
1628
[[mvc-view-tiles-url]]
1629
- ==== UrlBasedViewResolver
1629
+ ==== View Resolver
1630
1630
1631
1631
The `UrlBasedViewResolver` instantiates the given `viewClass` for each view it has to
1632
1632
resolve.
@@ -1641,7 +1641,7 @@ resolve.
1641
1641
1642
1642
1643
1643
[[mvc-view-tiles-resource]]
1644
- ==== ResourceBundleViewResolver
1644
+ ==== Resource Bundle
1645
1645
1646
1646
The `ResourceBundleViewResolver` has to be provided with a property file containing
1647
1647
viewnames and viewclasses the resolver can use:
@@ -1677,7 +1677,7 @@ box.
1677
1677
1678
1678
1679
1679
[[mvc-view-tiles-preparer]]
1680
- ==== SimpleSpringPreparerFactory and SpringBeanPreparerFactory
1680
+ ==== Preparer Factories
1681
1681
1682
1682
As an advanced feature, Spring also supports two special Tiles `PreparerFactory`
1683
1683
implementations. Check out the Tiles documentation for details on how to use
@@ -1728,10 +1728,6 @@ naturally deals with XML, or if your model can easily be converted to XML. The f
1728
1728
section shows how to produce an XML document as model data and have it transformed with
1729
1729
XSLT in a Spring Web MVC application.
1730
1730
1731
-
1732
-
1733
- [[mvc-view-xslt-firstwords]]
1734
- === My First Words
1735
1731
This example is a trivial Spring application that creates a list of words in the
1736
1732
`Controller` and adds them to the model map. The map is returned along with the view
1737
1733
name of our XSLT view. See <<mvc-controller>> for details of Spring Web MVC's
@@ -1740,7 +1736,7 @@ document ready for transformation.
1740
1736
1741
1737
1742
1738
[[mvc-view-xslt-beandefs]]
1743
- ==== Bean definitions
1739
+ === Beans
1744
1740
Configuration is standard for a simple Spring application.
1745
1741
The MVC configuration has to define a `XsltViewResolver` bean and
1746
1742
regular MVC annotation configuration.
@@ -1768,7 +1764,7 @@ And we need a Controller that encapsulates our word generation logic.
1768
1764
1769
1765
1770
1766
[[mvc-view-xslt-controllercode]]
1771
- ==== Standard MVC controller code
1767
+ === Controller
1772
1768
1773
1769
The controller logic is encapsulated in a `@Controller` class, with the
1774
1770
handler method being defined like so...
@@ -1814,7 +1810,7 @@ DOM document into it to generate our view.
1814
1810
1815
1811
1816
1812
[[mvc-view-xslt-transforming]]
1817
- ==== Document transformation
1813
+ === Transformation
1818
1814
1819
1815
Finally, the `XsltViewResolver` will resolve the "home" XSLT template file and merge the
1820
1816
DOM document into it to generate our view. As shown in the `XsltViewResolver`
@@ -1871,7 +1867,7 @@ This is rendered as:
1871
1867
----
1872
1868
1873
1869
[[mvc-view-document]]
1874
- == Document views ( PDF/ Excel)
1870
+ == PDF, Excel
1875
1871
1876
1872
1877
1873
@@ -1889,15 +1885,15 @@ for PDF generation, the iText library.
1889
1885
1890
1886
1891
1887
[[mvc-view-document-config]]
1892
- === Configuration and setup
1888
+ === Configuration
1893
1889
Document based views are handled in an almost identical fashion to XSLT views, and the
1894
1890
following sections build upon the previous one by demonstrating how the same controller
1895
1891
used in the XSLT example is invoked to render the same model as both a PDF document and
1896
1892
an Excel spreadsheet (which can also be viewed or manipulated in Open Office).
1897
1893
1898
1894
1899
1895
[[mvc-view-document-configviews]]
1900
- ==== Document view definitions
1896
+ === View definition
1901
1897
First, let's amend the views.properties file (or xml equivalent) and add a simple view
1902
1898
definition for both document types. The entire file now looks like this with the XSLT
1903
1899
view shown from earlier:
@@ -1919,15 +1915,15 @@ model data to, specify the location as the 'url' property in the view definition
1919
1915
1920
1916
1921
1917
[[mvc-view-document-configcontroller]]
1922
- ==== Controller code
1918
+ === Controller
1923
1919
The controller code we'll use remains exactly the same from the XSLT example earlier
1924
1920
other than to change the name of the view to use. Of course, you could be clever and
1925
1921
have this selected based on a URL parameter or some other logic - proof that Spring
1926
1922
really is very good at decoupling the views from the controllers!
1927
1923
1928
1924
1929
1925
[[mvc-view-document-configsubclasses]]
1930
- ==== Subclassing for Excel views
1926
+ === Excel views
1931
1927
Exactly as we did for the XSLT example, we'll subclass suitable abstract classes in
1932
1928
order to implement custom behavior in generating our output documents. For Excel, this
1933
1929
involves writing a subclass of
@@ -2011,7 +2007,7 @@ same page as before.
2011
2007
2012
2008
2013
2009
[[mvc-view-document-configsubclasspdf]]
2014
- ==== Subclassing for PDF views
2010
+ === PDF views
2015
2011
The PDF version of the word list is even simpler. This time, the class extends
2016
2012
`org.springframework.web.servlet.view.document.AbstractPdfView` and implements the
2017
2013
`buildPdfDocument()` method as follows:
@@ -2044,7 +2040,7 @@ document should appear listing each of the words in the model map.
2044
2040
2045
2041
2046
2042
[[mvc-view-feeds]]
2047
- == Feed Views
2043
+ == RSS Feeds
2048
2044
Both `AbstractAtomFeedView` and `AbstractRssFeedView` inherit from the base class
2049
2045
`AbstractFeedView` and are used to provide Atom and RSS Feed views respectfully. They
2050
2046
are based on java.net's https://rome.dev.java.net[ROME] project and are located in the
@@ -2105,10 +2101,11 @@ For an example of creating an Atom view please refer to Alef Arendsen's Spring T
2105
2101
https://spring.io/blog/2009/03/16/adding-an-atom-view-to-an-application-using-spring-s-rest-support[entry].
2106
2102
2107
2103
2108
-
2104
+ [[mvc-view-jackson]]
2105
+ == Jackson
2109
2106
2110
2107
[[mvc-view-json-mapping]]
2111
- == JSON Mapping View
2108
+ === JSON
2112
2109
The `MappingJackson2JsonView` uses the Jackson library's `ObjectMapper` to render the response
2113
2110
content as JSON. By default, the entire contents of the model map (with the exception of
2114
2111
framework-specific classes) will be encoded as JSON. For cases where the contents of the
@@ -2130,7 +2127,7 @@ name(s) could be customized through the `jsonpParameterNames` property.
2130
2127
2131
2128
2132
2129
[[mvc-view-xml-mapping]]
2133
- == XML Mapping View
2130
+ === XML
2134
2131
The `MappingJackson2XmlView` uses the
2135
2132
https://github.com/FasterXML/jackson-dataformat-xml[Jackson XML extension]'s `XmlMapper`
2136
2133
to render the response content as XML. If the model contains multiples entries, the
0 commit comments