Normally to return JSON from my Controllers methods, I add a @ResponseBody annotation and I let Jackson to map my returned object as JSON. No problem here.
However in this question, the OP says “my other methods that use @RequestMapping return void, and I can still get JSON from them through ajax”.
I was wondering how’s that possible? I’ve no reason to doubt, that he’s indeed doing that, so I would like to know how to do that, for the sake of curiosity and enhancing my Spring understanding.
You can write directly to the HttpServletResponse: