如题,在接收前端传过来的数据时,代码如下
@ResponseBody
@PostMapping(value = "/test",produces = "application/json;charset=utf-8")
public JSONObject test(@RequestBody UserClass userClass){
JSONObject jsonObject = new JSONObject();
jsonObject.put("test",userClass.getUsername());
return jsonObject;
}
报错为:
Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class org.json.JSONObject] with preset Content-Type 'null']
将方法类型改为String或者UserClass时就不会报错,请问该怎么解决?