You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in #18178, @RequestMapping"produces" attribute is used for mapping purpose, but also to generate the response content type.
With converters like MappingJackson2HttpMessageConverter when the default MediaType also specify the charset to use, overriding this attribute with "produces" = MediaType.APPLICATION_JSON_VALUE will change response encoding, even that not what most users are expecting (most of them just want to narrow the mapping without affecting the charset).
The goal of this issue is to find if there is a way to easily make it possible to override the mapping related to produces without "reseting" the charset used.
Just a quick note that this is not only about the produces condition. The Content-Type used in the response may also come from the "requested" content type as determined through a ContentNegotiationStrategy. For example path extension "json" registered against "application/json" will have the same effect.
The Content-Type used in the response may also come from the "requested" content type as determined through a ContentNegotiationStrategy. For example path extension "json" registered against "application/json" will have the same effect.
Has sense… perhaps a kind of interceptor should be applied to return always with UTF-8. Of course the user "perhaps" should not be aware about that.
Even more, related with the previous point, in the coming weeks I am going to do my own detailed experiments working with Rest. It in case the RestTemplate sets the Accept to only Json and the content data returns with the weird characters.
My original post #18178 was tested only through a Web Browser. No tested yet through a RestTemplate client.
I have updated the commit with Rossen feedback about ObjectToStringHttpMessageConverter and StringHttpMessageConverter, and will merge it shortly in master.
Activity
spring-projects-issues commentedon Nov 2, 2015
Sébastien Deleuze commented
See also this comment about the potential cause of this issue.
spring-projects-issues commentedon Nov 2, 2015
Rossen Stoyanchev commented
Just a quick note that this is not only about the produces condition. The Content-Type used in the response may also come from the "requested" content type as determined through a ContentNegotiationStrategy. For example path extension "json" registered against "application/json" will have the same effect.
spring-projects-issues commentedon Nov 3, 2015
Manuel Jordan commented
Hello
Has sense… perhaps a kind of interceptor should be applied to return always with UTF-8. Of course the user "perhaps" should not be aware about that.
Even more, related with the previous point, in the coming weeks I am going to do my own detailed experiments working with Rest. It in case the RestTemplate sets the Accept to only Json and the content data returns with the weird characters.
My original post #18178 was tested only through a Web Browser. No tested yet through a RestTemplate client.
-Manuel
spring-projects-issues commentedon Feb 23, 2016
Sébastien Deleuze commented
Rossen Stoyanchev Could you please review the fix I implemented with this commit?
spring-projects-issues commentedon Feb 29, 2016
Sébastien Deleuze commented
I have updated the commit with Rossen feedback about
ObjectToStringHttpMessageConverterandStringHttpMessageConverter, and will merge it shortly in master.