Skip to content

@ResponseBody overwrites ContentType [SPR-6559] #11225

@spring-projects-issues

Description

@spring-projects-issues

matthias boehmer opened SPR-6559 and commented

I have a controller with a method returning a simple string that contains a JSON object. The HttpServletRespose is avaiable as a method parameter. When I try to set the content type of the response to "application/json" is gets overwritten when I use @ResponseBody for mapping the return value to the response. It works well when I set the return type to void and write the response body directly into the HttpServletResponse using response.getWriter().write(jsonString).

Should not it be possible to set the content type, when I use @ResponseBody? This might be a bug, or at least it should be documented that @ResponseBody implicitly sets the content type.


Issue Links:

Metadata

Metadata

Assignees

Labels

status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions