Add Jackson 2 HttpMessageConverter and View
Jackson 2 uses completely new package names and new maven artifact ids. This change adds Jackson 2 as an optional dependency and also provides MappingJackson2HttpMessageConverter and MappingJackson2JsonView for use with the new version. The MVC namespace and the MVC Java config detect and use MappingJackson2HttpMessageConverter if Jackson 2 is present. Otherwise if Jackson 1.x is present, then MappingJacksonHttpMessageConverter is used. Issue: SPR-9302
This commit is contained in:
1
src/dist/changelog.txt
vendored
1
src/dist/changelog.txt
vendored
@@ -13,6 +13,7 @@ Changes in version 3.2 M1
|
||||
* fix case-sensitivity issue with some containers on access to 'Content-Disposition' header
|
||||
* add Servlet 3.0 based async support
|
||||
* fix issue with encoded params in UriComponentsBuilder
|
||||
* add Jackson 2 HttpMessageConverter and View types
|
||||
|
||||
Changes in version 3.1.1 (2012-02-16)
|
||||
-------------------------------------
|
||||
|
||||
@@ -2892,7 +2892,7 @@ public String upload(...) {
|
||||
</property>
|
||||
<property name="defaultViews">
|
||||
<list>
|
||||
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
|
||||
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
@@ -2924,7 +2924,7 @@ public String upload(...) {
|
||||
the <classname>SampleContentAtomView</classname> if the view name
|
||||
returned is <classname>content</classname>. If the request is made with
|
||||
the file extension <literal>.json</literal>, the
|
||||
<classname>MappingJacksonJsonView</classname> instance from the
|
||||
<classname>MappingJackson2JsonView</classname>instance from the
|
||||
<literal>DefaultViews</literal> list will be selected regardless of the
|
||||
view name. Alternatively, client requests can be made without a file
|
||||
extension but with the <literal>Accept</literal> header set to the
|
||||
@@ -3588,7 +3588,7 @@ public String onSubmit(<emphasis role="bold">@RequestPart("meta-data") MetaData
|
||||
However, the <literal>@RequestPart("meta-data") MetaData</literal>
|
||||
method argument in this case is read as JSON content based on its
|
||||
<literal>'Content-Type'</literal> header and converted with the help of
|
||||
the <classname>MappingJacksonHttpMessageConverter</classname>.</para>
|
||||
the <classname>MappingJackson2HttpMessageConverter</classname>.</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -4256,9 +4256,10 @@ public class WebConfig {
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><classname>MappingJacksonHttpMessageConverter</classname>
|
||||
converts to/from JSON — added if Jackson is present on the
|
||||
classpath.</para>
|
||||
<para><classname>MappingJackson2HttpMessageConverter</classname>
|
||||
(or <classname>MappingJacksonHttpMessageConverter</classname>)
|
||||
converts to/from JSON — added if Jackson 2 (or Jackson) is present
|
||||
on the classpath.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
|
||||
@@ -1363,7 +1363,7 @@ if (HttpStatus.SC_CREATED == post.getStatusCode()) {
|
||||
these defaults using the <methodname>messageConverters()</methodname> bean
|
||||
property as would be required if using the
|
||||
<classname>MarshallingHttpMessageConverter</classname> or
|
||||
<classname>MappingJacksonHttpMessageConverter</classname>.</para>
|
||||
<classname>MappingJackson2HttpMessageConverter</classname>.</para>
|
||||
|
||||
<para>Each method takes URI template arguments in two forms, either as a
|
||||
<literal>String</literal> variable length argument or a
|
||||
@@ -1608,7 +1608,7 @@ String body = response.getBody();</programlisting>
|
||||
</section>
|
||||
|
||||
<section id="rest-mapping-json-converter">
|
||||
<title>MappingJacksonHttpMessageConverter</title>
|
||||
<title>MappingJackson2HttpMessageConverter (or MappingJacksonHttpMessageConverter with Jackson 1.x)</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
implementation that can read and write JSON using Jackson's
|
||||
|
||||
@@ -2626,7 +2626,9 @@ simpleReport.reportDataKey=myBeanData</programlisting>
|
||||
<section id="view-json-mapping">
|
||||
<title>JSON Mapping View</title>
|
||||
|
||||
<para>The <classname>MappingJacksonJsonView</classname> uses the Jackson
|
||||
<para>The <classname>MappingJackson2JsonView</classname>
|
||||
(or <classname>MappingJacksonJsonView</classname> depending on the
|
||||
the Jackson version you have) uses the Jackson
|
||||
library's <classname>ObjectMapper</classname> 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
|
||||
|
||||
Reference in New Issue
Block a user