Steps to return json view from Spring controller
My request is ajax based and am calling to one of spring multiaction controlle开发者_开发问答r method,I able to create json file using Gson library. Is any way to return json view from controller method.
You can just let your method return the JSON String if you use the @ResponseBody
annotation and use one of the methods listed in the answers to my previous question:
In Spring MVC, how can I set the mime type header when using
@ResponseBody
I'm a total newbie but I've read some where that when you dont specify any logical view mapping for a controller and you return a model map from a handler method (@Controller
, @RequestMapping
) it should transform the model object to json and return it.
精彩评论