报错:expect 200, but 500

来源:3-2 查询请求

taoy

2018-01-09

按照课程来写,一开始运行报 500,服务器出错,看控制台如如下输出:

Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: 

Could not write JSON: No serializer found for class com.imooc.dto.User and no properties discovered to create BeanSerializer 

(to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); 

nested exception is com.fasterxml.jackson.databind.JsonMappingException:

No serializer found for class com.imooc.dto.User and no properties discovered to create BeanSerializer

(to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])

感觉应该是User类的内容都是null造成的,然后给User类的属性都赋好值(加了有参数的构造器),再放到list中就好用了,然后想再重现一下问题,把User类的属性值都设为空(就是使用无参构造器产生类),结果问题竟不能重现了,这是一种什么情况?

写回答

1回答

JoJo

2018-01-10

额..要看代码,看你的描述我实在想象不出来是什么问题...

1
1
taoy
非常感谢!
2018-01-10
共1条回复

Spring Security技术栈开发企业级认证与授权

Spring Security技术栈,REST风格开发常见接口,独立开发认证授权模块保证REST服务安全

2662 学习 · 1561 问题

查看课程

相似问题