提交 30667b34 编写于 作者: J Juergen Hoeller

Typo fixes and formatting

上级 bd681014
......@@ -273,21 +273,21 @@ The parameters to any of the above macros have consistent meanings:
field. The keys to the map represent the values that will be POSTed back from the form
and bound to the command object. Map objects stored against the keys are the labels
displayed on the form to the user and may be different from the corresponding values
posted back by the form. Usually such a map is supplied as reference data by the
controller. Any Map implementation can be used depending on required behavior. For
strictly sorted maps, a `SortedMap` such as a `TreeMap` with a suitable Comparator may
be used and for arbitrary Maps that should return values in insertion order, use a
`LinkedHashMap` or a `LinkedMap` from commons-collections.
* separator: where multiple options are available as discreet elements (radio buttons or
checkboxes), the sequence of characters used to separate each one in the list (ie
"<br>").
* attributes: an additional string of arbitrary tags or text to be included within the
HTML tag itself. This string is echoed literally by the macro. For example, in a
textarea field you may supply attributes as 'rows="5" cols="60"' or you could pass
style information such as 'style="border:1px solid silver"'.
* classOrStyle: for the showErrors macro, the name of the CSS class that the span tag
wrapping each error will use. If no information is supplied (or the value is empty)
then the errors will be wrapped in <b></b> tags.
posted back by the form. Usually, such a map is supplied as reference data by the
controller. You can use any `Map` implementation, depending on required behavior.
For strictly sorted maps, you can use a `SortedMap` (such as a `TreeMap`) with a
suitable `Comparator` and, for arbitrary Maps that should return values in insertion
order, use a `LinkedHashMap` or a `LinkedMap` from `commons-collections`.
* `separator`: Where multiple options are available as discreet elements (radio buttons
or checkboxes), the sequence of characters used to separate each one in the list
(such as `<br>`).
* `attributes`: An additional string of arbitrary tags or text to be included within
the HTML tag itself. This string is echoed literally by the macro. For example, in a
`textarea` field, you may supply attributes (such as 'rows="5" cols="60"'), or you
could pass style information such as 'style="border:1px solid silver"'.
* `classOrStyle`: For the `showErrors` macro, the name of the CSS class that the `span`
element that wraps each error uses. If no information is supplied (or the value is
empty), the errors are wrapped in `<b></b>` tags.
Examples of the macros are outlined below some in FTL and some in VTL. Where usage
differences exist between the two languages, they are explained in the notes.
......@@ -750,12 +750,12 @@ The Spring Framework has a built-in integration for using Spring MVC with JSP an
[[mvc-view-jsp-resolver]]
=== View resolvers
When developing with JSPs you can declare a `InternalResourceViewResolver` or a
When developing with JSPs, you can declare a `InternalResourceViewResolver` or a
`ResourceBundleViewResolver` bean.
`ResourceBundleViewResolver` relies on a properties file to define the view names
mapped to a class and a URL. With a `ResourceBundleViewResolver` you
can mix different types of views using only one resolver. Here is an example:
mapped to a class and a URL. With a `ResourceBundleViewResolver`, you can mix
different types of views by using only one resolver, as the following example shows:
[source,xml,indent=0]
[subs="verbatim,quotes"]
......@@ -765,7 +765,7 @@ can mix different types of views using only one resolver. Here is an example:
<property name="basename" value="views"/>
</bean>
# And a sample properties file is uses (views.properties in WEB-INF/classes):
# And a sample properties file is used (views.properties in WEB-INF/classes):
welcome.(class)=org.springframework.web.servlet.view.JstlView
welcome.url=/WEB-INF/jsp/welcome.jsp
......@@ -773,9 +773,9 @@ can mix different types of views using only one resolver. Here is an example:
productList.url=/WEB-INF/jsp/productlist.jsp
----
`InternalResourceBundleViewResolver` can also be used 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 also be used 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"]
......@@ -792,8 +792,8 @@ directory so there can be no direct access by clients.
[[mvc-view-jsp-jstl]]
=== JSPs versus JSTL
When using the Java Standard Tag Library you must use a special view class, the
`JstlView`, as JSTL needs some preparation before things such as the I18N features will
When using the JSP Standard Tag Library (JSTL) you must use a special view class, the
`JstlView`, as JSTL needs some preparation before things such as the I18N features can
work.
......@@ -1504,7 +1504,7 @@ or see the tag library description.
A key principle of REST is the use of the Uniform Interface. This means that all
resources (URLs) can be manipulated using the same four HTTP methods: GET, PUT, POST,
and DELETE. For each method, the HTTP specification defines the exact semantics. For
instance, a GET should always be a safe operation, meaning that is has no side effects,
instance, a GET should always be a safe operation, meaning that it has no side effects,
and a PUT or DELETE should be idempotent, meaning that you can repeat these operations
over and over again, but the end result should be the same. While HTTP defines these
four methods, HTML only supports two: GET and POST. Fortunately, there are two possible
......@@ -1516,9 +1516,8 @@ web framework (not just Spring MVC). Simply add this filter to your web.xml, and
with a hidden _method parameter will be converted into the corresponding HTTP method
request.
To support HTTP method conversion the Spring MVC form tag was updated to support setting
the HTTP method. For example, the following snippet taken from the updated Petclinic
sample
To support HTTP method conversion, the Spring MVC form tag was updated to support setting
the HTTP method. For example, the following snippet comes from the Pet Clinic sample:
[source,xml,indent=0]
[subs="verbatim,quotes"]
......@@ -1528,9 +1527,9 @@ sample
</form:form>
----
This will actually perform an HTTP POST, with the 'real' DELETE method hidden behind a
request parameter, to be picked up by the `HiddenHttpMethodFilter`, as defined in
web.xml:
The preceding example performs an HTTP POST, with the 'real' DELETE method hidden behind
a request parameter. It is picked up by the `HiddenHttpMethodFilter`, which is defined in
web.xml, as the following example shows:
[source,java,indent=0]
[subs="verbatim,quotes"]
......@@ -1714,17 +1713,18 @@ implementations. Check out the Tiles documentation for details on how to use
Specify `SimpleSpringPreparerFactory` to autowire ViewPreparer instances based on
specified preparer classes, applying Spring's container callbacks as well as applying
configured Spring BeanPostProcessors. If Spring's context-wide annotation-config has
been activated, annotations in ViewPreparer classes will be automatically detected and
applied. Note that this expects preparer __classes__ in the Tiles definition files, just
like the default `PreparerFactory` does.
configured Spring BeanPostProcessors. If Spring's context-wide annotation configuration has
been activated, annotations in `ViewPreparer` classes are automatically detected and
applied. Note that this expects preparer classes in the Tiles definition files, as
the default `PreparerFactory` does.
Specify `SpringBeanPreparerFactory` to operate on specified preparer __names__ instead
of classes, obtaining the corresponding Spring bean from the DispatcherServlet's
application context. The full bean creation process will be in the control of the Spring
application context in this case, allowing for the use of explicit dependency injection
configuration, scoped beans etc. Note that you need to define one Spring bean definition
per preparer name (as used in your Tiles definitions).
configuration, scoped beans, and so on. Note that you need to define one Spring bean definition
for each preparer name (as used in your Tiles definitions). The following example shows
how to define a `SpringBeanPreparerFactory` property on a `TilesConfigurer` bean:
[source,xml,indent=0]
[subs="verbatim,quotes"]
......@@ -1787,7 +1787,7 @@ Similar requirements apply for implementing `AbstractRssFeedView`, as shown belo
[source,java,indent=0]
[subs="verbatim,quotes"]
----
public class SampleContentAtomView extends AbstractRssFeedView {
public class SampleContentRssView extends AbstractRssFeedView {
@Override
protected void buildFeedMetadata(Map<String, Object> model,
......@@ -1828,16 +1828,13 @@ dynamically from the model data. The document is the view and will be streamed f
server with the correct content type to (hopefully) enable the client PC to run their
spreadsheet or PDF viewer application in response.
In order to use Excel views, you need to add the Apache POI library to your classpath,
and for PDF generation preferably the OpenPDF library.
In order to use Excel views, you need to add the Apache POI library to your classpath.
For PDF generation, you need to add (preferably) the OpenPDF library.
[NOTE]
====
Use the latest versions of the underlying document generation libraries if possible.
In particular, we strongly recommend OpenPDF (e.g. OpenPDF 1.0.5) instead of the
outdated original iText 2.1.7 since it is actively maintained and fixes an important
vulnerability for untrusted PDF content.
====
NOTE: You should use the latest versions of the underlying document-generation libraries,
if possible. In particular, we strongly recommend OpenPDF (for example, OpenPDF 1.0.5)
instead of the outdated original iText 2.1.7, since OpenPDF is actively maintained and
fixes an important vulnerability for untrusted PDF content.
......@@ -1896,11 +1893,11 @@ an external definition (by name) or as a `View` instance from the handler method
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 `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.
framework-specific classes) are encoded as JSON. For cases where the contents of the
map need to be filtered, you can specify a specific set of model attributes to encode
by using the `modelKeys` property. You can also use the `extractValueFromSingleKeyModel`
property 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
......@@ -1918,11 +1915,11 @@ Spring Framework 5.1, <<mvc-cors,CORS>> should be used instead.
=== Jackson-based XML views
[.small]#<<web-reactive.adoc#webflux-view-httpmessagewriter,Same in Spring WebFlux>>#
The `MappingJackson2XmlView` uses the
https://github.com/FasterXML/jackson-dataformat-xml[Jackson XML extension]'s `XmlMapper`
to render the response content as XML. If the model contains multiples entries, the
object to be serialized should be set explicitly using the `modelKey` bean property.
If the model contains a single entry, it will be serialized automatically.
`MappingJackson2XmlView` uses the
https://github.com/FasterXML/jackson-dataformat-xml[Jackson XML extension's] `XmlMapper`
to render the response content as XML. If the model contains multiple entries, you should
explicitly set the object to be serialized by using the `modelKey` bean property. If the
model contains a single entry, it is serialized automatically.
XML mapping can be customized as needed through the use of JAXB or Jackson's provided
annotations. When further control is needed, a custom `XmlMapper` can be injected
......@@ -1935,13 +1932,12 @@ serializers/deserializers need to be provided for specific types.
[[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 ``MarshallingView``'s `modelKey` bean property. Alternatively, the view
will iterate over all model properties and marshal the first type that is supported
The `MarshallingView` uses an XML `Marshaller` (defined in the `org.springframework.oxm`
package) to render the response content as XML. You can explicitly set the object to be
marshalled by using a `MarshallingView` instance's `modelKey` bean property. Alternatively,
the view iterates over all model properties and marshals 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
<<data-access.adoc#oxm,Marshalling XML using O/X Mappers>>.
`org.springframework.oxm` package, see <<data-access.adoc#oxm,Marshalling XML using O/X Mappers>>.
......
......@@ -2310,11 +2310,11 @@ Spring MVC has two main abstractions in support of flash attributes. `FlashMap`
to hold flash attributes while `FlashMapManager` is used to store, retrieve, and manage
`FlashMap` instances.
Flash attribute support is always "on" and does not need to enabled explicitly although
if not used, it never causes HTTP session creation. On each request there is an "input"
`FlashMap` with attributes passed from a previous request (if any) and an "output"
`FlashMap` with attributes to save for a subsequent request. Both `FlashMap` instances
are accessible from anywhere in Spring MVC through static methods in
Flash attribute support is always "`on`" and does not need to be enabled explicitly.
However, if not used, it never causes HTTP session creation. On each request, there is an
"`input`" `FlashMap` with attributes passed from a previous request (if any) and an
"`output`" `FlashMap` with attributes to save for a subsequent request. Both `FlashMap`
instances are accessible from anywhere in Spring MVC through static methods in
`RequestContextUtils`.
Annotated controllers typically do not need to work with `FlashMap` directly. Instead an
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册