Document why "charset=UTF-8" is specified for JSON

Issue: SPR-14715
This commit is contained in:
sdeleuze
2018-04-09 11:54:23 +02:00
parent 007da2a58d
commit 3879179927
4 changed files with 34 additions and 6 deletions

View File

@@ -1192,7 +1192,7 @@ overrides rather than extend the class level declaration.
[TIP]
====
`MediaType` provides constants for commonly used media types -- e.g.
`APPLICATION_JSON_VALUE`, `APPLICATION_JSON_UTF8_VALUE`.
`APPLICATION_JSON_VALUE`, `APPLICATION_XML_VALUE`.
====
@@ -1216,6 +1216,14 @@ content types that a controller method produces:
The media type can specify a character set. Negated expressions are supported -- e.g.
`!text/plain` means any content type other than "text/plain".
[NOTE]
====
For JSON content type, the UTF-8 charset should be specified even if
https://tools.ietf.org/html/rfc7159#section-11[RFC7159]
clearly states that "no charset parameter is defined for this registration" because some
browsers require it for interpreting correctly UTF-8 special characters.
====
You can declare a shared produces attribute at the class level. Unlike most other request
mapping attributes however when used at the class level, a method-level produces attribute
overrides rather than extend the class level declaration.
@@ -1223,7 +1231,7 @@ overrides rather than extend the class level declaration.
[TIP]
====
`MediaType` provides constants for commonly used media types -- e.g.
`APPLICATION_JSON_VALUE`, `APPLICATION_JSON_UTF8_VALUE`.
`APPLICATION_JSON_UTF8_VALUE`, `APPLICATION_XML_VALUE`.
====

View File

@@ -1425,7 +1425,7 @@ will overrides rather than extend the class level declaration.
[TIP]
====
`MediaType` provides constants for commonly used media types -- e.g.
`APPLICATION_JSON_VALUE`, `APPLICATION_JSON_UTF8_VALUE`.
`APPLICATION_JSON_VALUE`, `APPLICATION_XML_VALUE`.
====
@@ -1449,6 +1449,14 @@ content types that a controller method produces:
The media type can specify a character set. Negated expressions are supported -- e.g.
`!text/plain` means any content type other than "text/plain".
[NOTE]
====
For JSON content type, the UTF-8 charset should be specified even if
https://tools.ietf.org/html/rfc7159#section-11[RFC7159]
clearly states that "no charset parameter is defined for this registration" because some
browsers require it for interpreting correctly UTF-8 special characters.
====
You can declare a shared produces attribute at the class level. Unlike most other request
mapping attributes however when used at the class level, a method-level produces attribute
will overrides rather than extend the class level declaration.
@@ -1456,7 +1464,7 @@ will overrides rather than extend the class level declaration.
[TIP]
====
`MediaType` provides constants for commonly used media types -- e.g.
`APPLICATION_JSON_VALUE`, `APPLICATION_JSON_UTF8_VALUE`.
`APPLICATION_JSON_UTF8_VALUE`, `APPLICATION_XML_VALUE`.
====