不是属性名称不匹配的问题
Ajax:
$.ajax({
type:"POST",
url:"${APP_PATH}/testcontroller/saveUser",
data:$("#form01").serialize(),
contentType:'application/json; charset=UTF-8',
dataType:"json",
success:function(message){
alert("保存成功!"+JSON.stringify(message));
},
error:function(message){
alert("保存失败!"+JSON.stringify(message));
}
})
控制层:
@RequestMapping(value="/saveUser",method=RequestMethod.POST)
public ModelAndView saveUser(@RequestBody User user) {
ModelAndView mv = new ModelAndView(new MappingJackson2JsonView());
User u = us.saveUser(user);
mv.addObject(user);
mv.setViewName("success");
return mv;
}