@ResponseBody返回json时,json数据丢失或者报错

现象:

  1.报错:There is a cycle in the hierarchy!

  2.返回至前台的json不完整,字段丢失。

错误原因:

  eg:entity1的属性有list<entitiy2>,entity2的字段中也含有entity1,即常见的双向关联;引发的死循环

解决方案:

  1.重写一个vo用于传输json

  2.@JsonIgnore

posted @ 2016-04-06 18:14  peak-c  阅读(1538)  评论(0编辑  收藏  举报