Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7904

Setting default charset in StringHttpMessageConverter

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.0.5
    • Fix Version/s: 3.1.2, 3.2 GA
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      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.

        Issue Links

          Activity

          Hide
          rstoya05-aop Rossen Stoyanchev added a comment -

          I think SPR-7504 will help.

          Show
          rstoya05-aop Rossen Stoyanchev added a comment - I think SPR-7504 will help.
          Hide
          schrepfler Srđan Šrepfler added a comment -

          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.

          Show
          schrepfler Srđan Šrepfler added a comment - 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.

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              tziem Thomas Ziem
              Last updater:
              Juergen Hoeller
            • Votes:
              3 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 25 weeks, 5 days ago