Could not write JSON document: (was java.lang.NullPointerException) (through reference chain
来源:互联网 发布:数控车床计算软件下载 编辑:程序博客网 时间:2024/05/24 06:41
刚刚测试提了个bug查询错误,就找了下,原因是json问题吧,看看报的错,看了看bean也没啥问题。后面找一下了;看到一个大哥说的恍然。。。原来是一个坑。
在项目中,我们都会建model包下的实体bean。每个实体的属性的数据类型可能用了基本类型;也可能用了包装类型,可能有时候在处理业务的时候null值的处理方式我们直接修改bean的字段类型为但是又没有把setter/getter方法重新生成,就比如我的一个字段类型仅仅把属性的基本类型(如double)改为包装类型(如Double),而并没有将setter/getter的类型一起修改。
这种情况会报错,而且报的错经常会让人摸不着头脑。下面列举了一种情况,是利用com.fasterxml.jackson将Entity序列化为Json字符串时出现上述疏忽报的错误:com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference
我的bean:
private Double receiveDis;
public double getReceiveDis() {
return receiveDis;
}
public void setReceiveDis(double receiveDis) {
this.receiveDis = receiveDis;
}
这个坑入得还真有点深。记录一下;希望大家注意了。
阅读全文
0 0
- Could not write JSON document: (was java.lang.NullPointerException) (through reference chain
- Could not write JSON: Infinite recursion (StackOverflowError) (through reference chain:
- Could not write JSON: Infinite recursion (StackOverflowError) (through reference chain:
- Could not create the view: An unexpected exception was thrown. java.lang.NullPointerException a
- Could not complete request java.lang.NullPointerException
- Could not write JSON: java.lang.Integer cannot be cast to java.math.BigInteger
- Spring MVC 解决 Could not write JSON: No serializer found for class java.lang.Object
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server.java.lang.NullPointerException
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server. Java.lang.NullPointerException
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server. java.lang.NullPointerException
- Could not publish to the server. Java.lang.NullPointerException
- Json -- java.Lang.NullPointerException
- 【云计算的1024种玩法】使用 NAS 文件储存低价获得好磁盘性能
- hammer.js自定义vue指令的简单例子
- tensorflow 去重
- 快速修改win系统的hosts文件
- Android Jni 利用OpenCV 实现图像尺寸缩放(一)
- Could not write JSON document: (was java.lang.NullPointerException) (through reference chain
- C语言基础与提高5
- JPA Specification常用查询+排序
- 你可能不知道的RoR 5点技巧
- H.264 打包 MPEG-TS 流
- wps自动备份的文件,备份到本地哪里了?
- 【097】Nginx实现一台服务器,两个域名发布不同的前端项目,并且两个域名都用80端口。
- 数据结构上机——哈夫曼树 线索二叉树
- 【第三方类库】Java Guava , Google Guava