Skip to content

StringHttpMessageConverter should use its default charset [SPR-14821] #19387

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions