接收JSON
1)在上面的项目中使用第一种方式处理返回JSON的基础上,增加如下方法:
Java代码
@RequestMapping(value="/add",method=RequestMethod.POST, headers = {"content-type=application/json","content-type=application/xml"})
@ResponseBody
public Object addUser(@RequestBody User user)
{
System.out.println(user.getName() + " " + user.getAge());
return new HashMap<String, String>().put("success", "true");
}