Issue 1:
Francisco Lozano opened SPR-9487 and commented

Spring for Android 's StringHttpMessageConverter has a very useful constructor which allows to specify a default charset different from ISO-8859-1:

/**
* 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<Charset>(Charset.availableCharsets().values()));
}

Could this be backported to full Spring's StringHttpMessageConverter

Affects: 3.1.1, 3.2 M1

Issue Links:

#13132 StringHttpMessageConverter doesn't work under UTF-8 ("is duplicated by")

#12559 Setting default charset in StringHttpMessageConverter ("is duplicated by")

Referenced from: commits 9aa43fc, 98b281e, a4240d2

Issue 2:
David Melia opened SPR-7905 and commented

Hi,

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

Accept=application/appname-v1+xml or Accept=application/appname-v1+json

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

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 <mvc:annotation-driven/> out of the box :-(

Any chance we could have MappingJacksonHttpMessageConverter also registering ```
new MediaType("application", "*+json", DEFAULT_CHARSET)

This would result in a lot less configuration as I have to do the following in place of mvc:annotation-driven/

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters" ref="messageConverters" />
</bean>
<!-- Message converters -->
<util:list id="messageConverters">
<bean class="org.springframework.http.converter.StringHttpMessageConverter" />
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg value="application" />
<constructor-arg value="json" />
</bean>
<bean class="org.springframework.http.MediaType">
<constructor-arg value="application" />
<constructor-arg value="*+json" />
</bean>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.FormHttpMessageConverter" />
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" />
</util:list>

Thanks

Affects: 3.0.5

Issue Links:

#14269 MediaType's include method does not check for generalization when using a format extension/suffix ("is duplicated by")

#14440 ContentNegotiatingViewResolver does not support wildcards in contentType

Referenced from: commits 8270d82, e16c403, 4f114a6

4 votes, 8 watchers