Skip to content
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

Setting default charset in StringHttpMessageConverter [SPR-7904] #12559

spring-projects-issues opened this issue Jan 24, 2011 · 2 comments


Copy link

@spring-projects-issues spring-projects-issues commented Jan 24, 2011

Thomas Ziem opened SPR-7904 and commented

Currently, StringHttpMessageConverter uses ISO-8859-1 as default charset for reading and writing:

public static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
protected String readInternal(Class clazz, HttpInputMessage inputMessage) throws IOException {
    MediaType contentType = inputMessage.getHeaders().getContentType();
    Charset charset = contentType.getCharSet() != null ? contentType.getCharSet() : DEFAULT_CHARSET;
    return FileCopyUtils.copyToString(new InputStreamReader(inputMessage.getBody(), charset));

It would be nice if it could be configured from outside.

Affects: 3.0.5

Issue Links:

  • #14122 Backport constructor accepting Charset in StringHttpMessageConverter, from Spring for Android to Spring Web. ("duplicates")
  • #12161 Make it easier to add new Message Converters to AnnotationMethodHandlerAdapter

Backported to: 3.1.2

3 votes, 1 watchers

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 28, 2011

Rossen Stoyanchev commented

I think SPR-7504 will help.

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Apr 1, 2014

Srđan Šrepfler commented

Please take into account this is used by spring integration as well so there should be a way to configure this which is not bound to the mvc framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants