Announcement Announcement Module
Collapse
No announcement yet.
JSON Content Type Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSON Content Type

    Hi,
    Greetings.
    I have a simple question on annotation driven JSON Mappings.
    The JSON output comes from Spring MVC defaults to content-type “application/json” how to override it to get JSON String as “text/plain”

    Thanks
    Venkat Muthusamy

  • #2
    There's a couple options I think.

    If this request is being made by an AJAX request, then if you're using DOJO for example, you can set the handleAs property to just "text". Also, you should set the "Accept" header as "text/plain" when making the request.

    Another option is in your @RequestMapping, you can set the "produces" property to "text/plain".

    Your last option is overriding the "Content-Type" header directly. Either by injecting the HttpServletResponse into your handler mapping and setting the "Content-Type" header manually, or by returning a ResponseEntity and setting the headers on the ResponseEntity.

    Comment

    Working...
    X