解决:Could not write JSON: No serializer found for class *** and no properties错误

简介: 解决:Could not write JSON: No serializer found for class *** and no properties错误

场景:使用RestController或者Controller注解将查询的实体装换成json字符串时报错。


原因:需要装换的对应实体类的属性缺少:getter和setter方法,导致将实体类装换的json格式类无法读取对应的属性从而报错。


解决方法:在需要装换的是实体类中给属性加上getter和setter方法(或者使用:lombok插件给实体类加上:Getter和Setter注解)


拓展:错误信息为:Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type...的原因同样是实体类缺少getter和setter方法,解决方式跟上面的错误一样。


相关文章
|
19天前
|
Java
Found multiple occurrences of org.json.JSONObject on the class path:
Found multiple occurrences of org.json.JSONObject on the class path:
14 0
|
2月前
|
JSON Java 数据格式
No converter for [class java.util.LinkedHashMap] with preset Content-Type 'text/json;charset=UTF-8']问题
【5月更文挑战第21天】No converter for [class java.util.LinkedHashMap] with preset Content-Type 'text/json;charset=UTF-8']问题
55 0
|
2月前
|
JSON Java 数据格式
No converter for [class java.util.HashMap] with preset Content-Type 'text/json;charset=UTF-8'问题
【5月更文挑战第21天】No converter for [class java.util.HashMap] with preset Content-Type 'text/json;charset=UTF-8'问题
50 0
|
2月前
|
JSON 前端开发 Java
JSON&yaml和Properties
JSON&yaml和Properties
26 0
|
2月前
|
JavaScript
【Vue Error】Virtual script not found, may missing <script lang=“ts“> “allowJs“: true / jsconfig.json
【Vue Error】Virtual script not found, may missing <script lang=“ts“> “allowJs“: true / jsconfig.json
|
8月前
|
资源调度 JavaScript Windows
yarn install命令报错解决办法-warning package-lock.json found.
yarn install命令报错解决办法-warning package-lock.json found.
143 0
|
8月前
|
JSON 监控 数据格式
Grafana导入 json 文件的 dashboard 错误 Templating Failed to upgrade legacy queries Datasource xxx not found
Grafana导入 json 文件的 dashboard 错误 Templating Failed to upgrade legacy queries Datasource xxx not found
228 0
|
JSON 前端开发 Java
【Json与Ajax交互报错解决】No converter found for return value of type: class com.github.pagehelper.PageInfo
【Json与Ajax交互报错解决】No converter found for return value of type: class com.github.pagehelper.PageInfo
293 0
【Json与Ajax交互报错解决】No converter found for return value of type: class com.github.pagehelper.PageInfo
|
JSON 数据格式
Could not write JSON: (was java.lang.NullPointerException); nested exception is...不出意外就是这个原因
出现这个报错百分之80都是实体类有问题,检查下实体类的get/set方法,有没有空指针 我这里是这样的,get方法忘了空判断
1725 0
使用json-lib-2.1.jar报,org.apache.struts2.json.JSONWriter can not access a member of class org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionW
http://blog.csdn.net/xtra6714/archive/2010/07/08/5721593.aspx 原因:action中,有get方法,且方法返回接口类型时,报些错误。 办法:去掉相关返回接口类型的get方法;
836 0