报错:
No serializer found for class com.example.domain.Men and no properties discovered to create Bean…
springboot中使用@RestController注解前台页面返回不到对象数据异常
异常信息
首页控制台会打印如下异常:
红色框里详细如下
No serializer found for class com.example.domain.Men and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])
原因:实体类没有写有对应的get()和set方法
解决
在实体类写上set() 和 get() 方法即可,并在其方法前要有public