Jackson解析toString(writeValueAsString)无响应
来源:互联网 发布:多尺度kcf跟踪算法 编辑:程序博客网 时间:2024/06/03 20:14
在学习使用Jackson时,看了http://blog.csdn.net/gjb724332682/article/details/51586701之后就下手写了个demo
public class CountryEntity implements Serializable { private String code; private String country; private String letter; public CountryEntity() { } public CountryEntity(String code, String country) { this.code = code; this.country = country; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public String getLetter() { return letter; } public void setLetter(String letter) { this.letter = letter; }}
一开始readValue和writeValueAsString时都能正常运行,后来为了使用默认参数,加了getDefault()
public CountryEntity getDefault() { return new CountryEntity("86", "中国"); }然后writeValueAsString就一直卡着,没有耐心等待,以为是耗时就去找问题了,最后发现问题,JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain),在http://zzc1684.iteye.com/blog/2186504中得知get/set方法会作为一种属性的方法,导致Infinite recursion,最后添加
@JsonIgnore解决:
@JsonIgnore public CountryEntity getDefault() { return new CountryEntity("86", "中国"); }要细心,认真看反馈。
阅读全文
0 0
- Jackson解析toString(writeValueAsString)无响应
- writeValueAsString
- 使用jackson的writeValueAsString把java对象输出成字符串实例,设置应答体的类型
- Jackson解析
- 无响应
- 使用HttpServletResponse响应数据-Jackson
- Retrofit 响应体无body时解析EOFException
- jackson解析 json字符串
- Jackson解析JSON例子
- Jackson解析JSON例子
- java json解析-jackson
- jackson框架解析json
- Jackson解析JSON数据
- Json解析工具Jackson
- Jackson解析JSON例子
- java json解析-jackson
- Json解析工具Jackson
- Jackson解析封装
- vue $nextTick( [callback] )使用场景
- 关于js中出现获取input框的值为[object HTMLInputElement]的问题
- 解决linux c利用openssl进行3des和安卓封装的接口加密解密出的字符串不一样的问题
- 为什么我的echarts字体样式这么丑?Echarts 柱状图、饼图 等标签、字体、样式调整
- 关于数据库事务知识的罗列----“足球论之事务的特征”
- Jackson解析toString(writeValueAsString)无响应
- 从svn上迁移项目到公司gitlab
- 如何实现python 2.x和3.X的相互兼容
- PHP创建PDF文件(通过FPDF类库)
- 谷歌浏览器微信扫码登陆报错的问题
- 主线程的子线程信息pool-1-thread-1
- spring与Hibernate整合代码截图
- 蓝牙协议分析(2)_协议架构
- 浅谈函数的调用过程,栈帧的创建和销毁,附图讲解