如题,在接收前端传过来的数据时,代码如下
@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时就不会报错,请问该怎么解决?
No converter for [class org.json.JSONObject] with preset Content-Type 'null,先确定是不是自己还有地方显式指定了conenttype,
第二,去掉 produces = "application/json;charset=utf-8",压根就不需要你指定json、
第三,请用默认jackson,放弃fastjson
删掉 ,produces = "application/json;charset=utf-8"