-
May 9th, 2012, 05:14 PM
#1
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
-
May 13th, 2012, 08:12 AM
#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.
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
-
Forum Rules