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

StringHttpMessageConverter should assume charset UTF-8 for application/json

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.1.3
    • Fix Version/s: 5.1.4
    • Component/s: Web, Web:Client
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When using "@RequestBody String jsonString" for an @Controller's @RequestMapping and the body is send as application/json with UTF-8 encoding, Spring uses StringHttpMessageConverter to convert the message, as the content-type will be application/json without any explicit encoding, so the StringHttpMessageConverter will fall back to the default encoding ISO-8859-1 which may is in accordance with the HTTP spec but not with RFC7159, which says: "The default encoding is UTF-8" (chapter 8.1)

       

      So the suggestion would be to add an exception in the StringHttpMessageConverter to use UTF-8 charset for application/json.

       

       

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            thomasmey Thomas Meyer
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 19 weeks, 1 day ago