开发者

How to get a JSON object and map it into object in spring 3.0 controller using POST method?

I want to add reques开发者_开发技巧t mapping my controller which gets a Json of Array of an object. The JSON will be sent from javascript using post.

Thanks, Kfir


You can do this using Spring's @RequestBody annotation, e.g.

@ResponseBody
public Map<String, Object> handleJsonPost(@RequestBody Map<String, Object> requestJson) {
   ...
   return responseJson;
}

This will also send the return value back as JSON.

You'll also need to include the Jackson library in your application's classpath, and add

<mvc:annotation-driven/> 

to your context (see docs)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜