Results 1 to 2 of 2

Thread: JSON Content Type

  1. #1
    Join Date
    Oct 2005
    Posts
    6

    Default 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. #2
    Join Date
    Nov 2009
    Location
    Montreal, Quebec
    Posts
    398

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •