@RequestMapping("/login")
@ResponseBody
public User login(User user){
return user;
}
User字段:userName pwd
那么在前臺(tái)接收到的數(shù)據(jù)為:'{"userName":"xxx","pwd":"xxx"}'
效果等同于如下代碼:
@RequestMapping("/login")
public void login(User user, HttpServletResponse response){
response.getWriter.write(JSONObject.fromObject(user).toString());
}