SpringMVC的controller中,对于一个ajax请求,想要将存在ResultEntity对象转为json数据传递给前端,但是一直报错:No converter found for return value of type: class xxx。说什么没有找到该针对该类型的合适的转换器。在ResultEntity类中补上set/get方法就行了。
@ResponseBody
@RequestMapping("/send/compose/object.json")
public ResultEntity<Student> testReceiveComposeObject(@RequestBody Student student){
ResultEntity<Student> resultEntity = ResultEntity.successWithData(student);
return resultEntity;
}