基于springboot的web项目提供restAPI接口无法解析对象的问题
@RequestMapping(value = "/")
@ResponseBody
public Result home() {
return new Result();
}
package org.demo.app;
import java.io.Serializable;
public class Result implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
private String name1;
private String name2;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getName1() {
return name1;
}
public void setName1(String name1) {
this.name1 = name1;
}
public String getName2() {
return name2;
}
public void setName2(String name2) {
this.name2 = name2;
}
}
package org.demo.app;
public class Result {
String name;
public String getName() {
return name;
}
}
当前这个返回对象,可以不实现序列号接口,但是必须要有字段,而且还要有字段的get方法否则就会出现如下的问题
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Nov 16 16:51:17 CST 2017
There was an unexpected error (type=Internal Server Error, status=500).
No converter found for return value of type: class org.demo.app.Result