New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StringHttpMessageConverter should use its default charset [SPR-14821] #19387
Comments
Yi commented The error my lies in org.springframework.http.MediaType.getCharSet() method, since I didn't set charset anywhere, this method should return null. |
Sébastien Deleuze commented Hi, to help me to reproduce the issue, could you specify what is the |
Yi commented Some request headers(same under both versions): Response headers under version 4.2.7: Response headers under version 4.3.3: |
Sébastien Deleuze commented I can't reproduce the issue, so could you please provide a sample project that demonstrates the problem? |
Yi commented I tried to make a sample project, and find that there's something wrong in my mvc configuration. correct configuration: |
Yi commented It's the first time I write issue to spring. Should I close this issue? I haven't seen a close button. |
Sébastien Deleuze commented I have resolved this issue as invalid, thanks for the update. |
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:
The text was updated successfully, but these errors were encountered: