springMVC怎么获取前台post过来的对象
1个回答
展开全部
@RequestMapping(value="/test",method=RequestMethod.POST)
public @ResponseBody Map<String, Object> testPostJson(
@RequestBody UserForm userForm,
BindingResult bindingResult) {
Map<String, Object> map = new HashMap<String, Object>();
if (bindingResult.hasErrors()) {
map.put("errorCode", "40001");
map.put("errorMsg", bindingResult.getFieldError().getDefaultMessage());
}
map.put("user", userForm);
return map;
}
public @ResponseBody Map<String, Object> testPostJson(
@RequestBody UserForm userForm,
BindingResult bindingResult) {
Map<String, Object> map = new HashMap<String, Object>();
if (bindingResult.hasErrors()) {
map.put("errorCode", "40001");
map.put("errorMsg", bindingResult.getFieldError().getDefaultMessage());
}
map.put("user", userForm);
return map;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询