Description
Yi opened SPR-14821 and commented
To set @responsebody
encoding in spring-webmvc, I used to add the following lines in configuration file:
mvc:annotation-driven
mvc:message-converters
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
</mvc:message-converters>
This override the default charset responsebody handler use. And it worked with spring-mvc version 4.2.7 and below.
However, in the latest version of spring-webmvc(4.3.3), this method does not work. In the new version, StringHttpMessageConverter reads content-type from response header, and if content-type string includes charset information, it use this charset and ignores it's default charset.
Affects: 4.3.1, 4.3.2, 4.3.3
Reference URL: http://stackoverflow.com/questions/40098647/responsebody-encoding-in-spring-mvc-4-3-3
Issue Links:
- Allow specifying HTTP response Content-Type without losing default charset [SPR-13631] #18209 Allow specifying HTTP response Content-Type without losing default charset