05-Apr-2020 12:51:01.346 璀﹀憡 [http-nio-8081-exec-8] org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.logException Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found forreturn value of type: class com.imooc.result.entity.Person]
public class Person {
private String username;
private int age;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return"Person{" +
"username='" + username + '\'' +
", age=" + age +
'}';
}
}
控制层
public Person getPersonMessage(@PathVariable("id") int id) {
Person person = null;
if (id == 1) {
person = new Person();
person.setAge(12);
person.setUsername("李四");
} else if (id == 2) {
person = new Person();
person.setAge(13);
person.setUsername("张三");
}
return person;
}