Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type:
@RestController或者@Controller + @ResoponseBody都已加过了还是提示该对象不能转换输出成json给前端?
请确认你的对象已经存在公共的getter方法,在自动转换过程中会用到getter方法
public class ResponseObject {
private int code;
private String msg;
private Object data;
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
public Object getData() {
return data;
}
public ResponseObject(int code, String msg){
this.code = code;
this.msg = msg;
}
public ResponseObject(int code, String msg, Object data) {
this.code = code;
this.msg = msg;
this.data = data;
}