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.

        Attachments

          Issue Links

            Activity

              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:
                  4 years, 12 weeks, 5 days ago