<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=flozano" rel="nofollow">Francisco Lozano</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9487?redirect=false" rel="nofollow">SPR-9487</a></strong> and commented</p>
<p dir="auto">Spring for Android 's StringHttpMessageConverter has a very useful constructor which allows to specify a default charset different from ISO-8859-1:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/**
 * Create a new StringHttpMessageConverter instance with a default {@link Charset},
 * and default list of available {@link Charset}'s from {@link Charset#availableCharsets()}.
 * @param defaultCharset the Charset to use 
 */
public StringHttpMessageConverter(Charset defaultCharset) {
	this(defaultCharset, new ArrayList&lt;Charset&gt;(Charset.availableCharsets().values()));
}"><pre class="notranslate"><span class="pl-c">/**</span>
<span class="pl-c"> * Create a new StringHttpMessageConverter instance with a default {@link Charset},</span>
<span class="pl-c"> * and default list of available {@link Charset}'s from {@link Charset#availableCharsets()}.</span>
<span class="pl-c"> * @param defaultCharset the Charset to use </span>
<span class="pl-c"> */</span>
<span class="pl-k">public</span> <span class="pl-s1">StringHttpMessageConverter</span>(<span class="pl-smi">Charset</span> <span class="pl-s1">defaultCharset</span>) {
	<span class="pl-smi">this</span>(<span class="pl-s1">defaultCharset</span>, <span class="pl-s1">new</span> <span class="pl-s1">ArrayList</span>&lt;<span class="pl-s1">Charset</span>&gt;(<span class="pl-smi">Charset</span>.<span class="pl-en">availableCharsets</span>().<span class="pl-en">values</span>()));
}</pre></div>
<p dir="auto">Could this be backported to full Spring's StringHttpMessageConverter</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1, 3.2 M1</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398113222" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13132" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13132/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13132">#13132</a> StringHttpMessageConverter doesn't work under UTF-8 (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398109788" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12559" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12559/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12559">#12559</a> Setting default charset in StringHttpMessageConverter (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/9aa43fcef6e4cc20104b89cc974f553bb6d77b67/hovercard" href="https://github.com/spring-projects/spring-framework/commit/9aa43fcef6e4cc20104b89cc974f553bb6d77b67"><tt>9aa43fc</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/98b281ea45aeee2f7ea8fcf941d7cac1f671c419/hovercard" href="https://github.com/spring-projects/spring-framework/commit/98b281ea45aeee2f7ea8fcf941d7cac1f671c419"><tt>98b281e</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/a4240d28643f5d6f7b435ce4512d240efc6db7b9/hovercard" href="https://github.com/spring-projects/spring-framework/commit/a4240d28643f5d6f7b435ce4512d240efc6db7b9"><tt>a4240d2</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=mzz6wh" rel="nofollow">David Melia</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7905?redirect=false" rel="nofollow">SPR-7905</a></strong> and commented</p>
<p dir="auto">Hi,</p>
<p dir="auto">Currently in my REST service which supports both XML and JSON I am using the accept header so the same URL can provide different end points which will provide versioning.  So my accept header is of the format</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Accept=application/appname-v1+xml or Accept=application/appname-v1+json"><pre class="notranslate"><code class="notranslate">Accept=application/appname-v1+xml or Accept=application/appname-v1+json
</code></pre></div>
<p dir="auto">which can route through the the v1 (version1) version of my REST method.  The above is fine for XML as AbstractXmlHttpMessageConverter (subclass of Jaxb2RootElementHttpMessageConverter) registers the media type</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="new MediaType(&quot;application&quot;, &quot;*+xml&quot;)
``` so this wildcard satisfies my accept header no problem.

However, for JSON, MappingJacksonHttpMessageConverter only registers ```
new MediaType(&quot;application&quot;, &quot;json&quot;, DEFAULT_CHARSET)
``` which means I cannot use &lt;mvc:annotation-driven/&gt; out of the box :-(

Any chance we could have MappingJacksonHttpMessageConverter also registering ```
new MediaType(&quot;application&quot;, &quot;*+json&quot;, DEFAULT_CHARSET)"><pre class="notranslate"><code class="notranslate">new MediaType("application", "*+xml")
``` so this wildcard satisfies my accept header no problem.

However, for JSON, MappingJacksonHttpMessageConverter only registers ```
new MediaType("application", "json", DEFAULT_CHARSET)
``` which means I cannot use &lt;mvc:annotation-driven/&gt; out of the box :-(

Any chance we could have MappingJacksonHttpMessageConverter also registering ```
new MediaType("application", "*+json", DEFAULT_CHARSET)
</code></pre></div>
<p dir="auto">This would result in a lot less configuration as I have to do the following in place of mvc:annotation-driven/</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean class=&quot;org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping&quot; /&gt;
&lt;bean class=&quot;org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter&quot;&gt;
   &lt;property name=&quot;messageConverters&quot; ref=&quot;messageConverters&quot; /&gt;
&lt;/bean&gt;
&lt;!-- Message converters --&gt;
&lt;util:list id=&quot;messageConverters&quot;&gt;
   &lt;bean class=&quot;org.springframework.http.converter.StringHttpMessageConverter&quot; /&gt;   
    &lt;bean class=&quot;org.springframework.http.converter.json.MappingJacksonHttpMessageConverter&quot;&gt;
       &lt;property name=&quot;supportedMediaTypes&quot;&gt;
          &lt;list&gt;
              &lt;bean class=&quot;org.springframework.http.MediaType&quot;&gt;
                 &lt;constructor-arg value=&quot;application&quot; /&gt;
                 &lt;constructor-arg value=&quot;json&quot; /&gt;
               &lt;/bean&gt; 
             &lt;bean class=&quot;org.springframework.http.MediaType&quot;&gt;
                &lt;constructor-arg value=&quot;application&quot; /&gt;
                &lt;constructor-arg value=&quot;*+json&quot; /&gt;
             &lt;/bean&gt;
          &lt;/list&gt;
       &lt;/property&gt;
    &lt;/bean&gt;
    &lt;bean class=&quot;org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter&quot; /&gt;
   &lt;bean class=&quot;org.springframework.http.converter.ByteArrayHttpMessageConverter&quot; /&gt;
   &lt;bean class=&quot;org.springframework.http.converter.FormHttpMessageConverter&quot; /&gt;
   &lt;bean class=&quot;org.springframework.http.converter.xml.SourceHttpMessageConverter&quot; /&gt;
&lt;/util:list&gt;	"><pre class="notranslate"><code class="notranslate">&lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /&gt;
&lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
   &lt;property name="messageConverters" ref="messageConverters" /&gt;
&lt;/bean&gt;
&lt;!-- Message converters --&gt;
&lt;util:list id="messageConverters"&gt;
   &lt;bean class="org.springframework.http.converter.StringHttpMessageConverter" /&gt;   
    &lt;bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&gt;
       &lt;property name="supportedMediaTypes"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.http.MediaType"&gt;
                 &lt;constructor-arg value="application" /&gt;
                 &lt;constructor-arg value="json" /&gt;
               &lt;/bean&gt; 
             &lt;bean class="org.springframework.http.MediaType"&gt;
                &lt;constructor-arg value="application" /&gt;
                &lt;constructor-arg value="*+json" /&gt;
             &lt;/bean&gt;
          &lt;/list&gt;
       &lt;/property&gt;
    &lt;/bean&gt;
    &lt;bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" /&gt;
   &lt;bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /&gt;
   &lt;bean class="org.springframework.http.converter.FormHttpMessageConverter" /&gt;
   &lt;bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" /&gt;
&lt;/util:list&gt;	
</code></pre></div>
<p dir="auto">Thanks</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398152097" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14269" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14269/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14269">#14269</a> MediaType's include method does not check for generalization when using a format extension/suffix (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398153512" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14440" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14440/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14440">#14440</a> ContentNegotiatingViewResolver does not support wildcards in contentType</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/8270d82bda85f227780f03e6cdcac9ae721118ad/hovercard" href="https://github.com/spring-projects/spring-framework/commit/8270d82bda85f227780f03e6cdcac9ae721118ad"><tt>8270d82</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/e16c40359a1809a647d0adfc2d7cfffcfaa9963a/hovercard" href="https://github.com/spring-projects/spring-framework/commit/e16c40359a1809a647d0adfc2d7cfffcfaa9963a"><tt>e16c403</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/4f114a657f71fd71b34509c686c5e8adce763c2d/hovercard" href="https://github.com/spring-projects/spring-framework/commit/4f114a657f71fd71b34509c686c5e8adce763c2d"><tt>4f114a6</tt></a></p>
<p dir="auto">4 votes, 8 watchers</p>