Add MediaType.APPLICATION_JSON_UTF8

Add new MediaType.APPLICATION_JSON_UTF8 and
MediaType.APPLICATION_JSON_UTF8_VALUE constants for
"application/json;charset=UTF-8" content type in order to make it
easier to override @RequestMapping "produces" attribute without
losing the default JSON charset (UTF-8).

Issue: SPR-13600
This commit is contained in:
Sebastien Deleuze
2015-11-03 12:20:39 +01:00
parent 23c8f712c4
commit 09cb286c84
4 changed files with 21 additions and 7 deletions

View File

@@ -1028,7 +1028,7 @@ condition. For example:
[subs="verbatim,quotes"]
----
@Controller
@RequestMapping(path = "/pets/{petId}", method = RequestMethod.GET, **produces="application/json; charset=UTF-8"**)
@RequestMapping(path = "/pets/{petId}", method = RequestMethod.GET, **produces = MediaType.APPLICATION_JSON_UTF8_VALUE**)
@ResponseBody
public Pet getPet(@PathVariable String petId, Model model) {
// implementation omitted
@@ -3855,7 +3855,7 @@ When writing error information, the status code and the error message set on the
@Controller
public class ErrorController {
@RequestMapping(path="/error", produces="application/json; charset=UTF-8")
@RequestMapping(path = "/error", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public Map<String, Object> handle(HttpServletRequest request) {