前台代码
$.ajax({
type:"post",
url: 'add',
contentType:"application/json; charset=utf-8",
dataType:"json",
data:JSON.stringify({
content:"nihaoahaha",
param:[{id:1,name:"hello"},{id:2,name:"hello"}]
}),
success:function(data){
console.log(data);
}
})
后台代码:
@ResponseBody
@RequestMapping(value = "add", consumes = "application/json; charset=utf-8")
public String add(@RequestBody String content, @RequestBody List<Tag> param) {
System.out.println("param:" + param);
return "成功";
}
报错信息:
2018-01-29 17:04:55.765 WARN 10768 --- [nio-8088-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public java.lang.String com.example.demo.controller.HelloController.add(java.lang.String,java.util.List<com.example.demo.entity.Tag>)
2018-01-29 17:04:55.765 WARN 10768 --- [nio-8088-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public java.lang.String com.example.demo.controller.HelloController.add(java.lang.String,java.util.List<com.example.demo.entity.Tag>)
开满天机
猛跑小猪
手掌心
相关分类