at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23) at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446) at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150) at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112) at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:72)
今天做显示商品评论功能 使用springmvc ajax加载,查询出来的数据转换成json时出现了死循环,如下:
引用
[{"commentid":22,"goods":{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产","goodses":[{"goodsid":8,"goodsarea":{"areaid":3,"areaName":"毕节特产",
查询评论表 而评论表和商品表是多对一的关系,商品表和分类表.地区表多对一的关系,
死循环原因:json无法对comments表的goods属性进行转换
解决办法:
在comments实体类上加注解@JsonIgnoreProperties(value={"goods"})
@JsonIgnoreProperties(value={"goods"}) public class Comments implements java.io.Serializable { // Fields /** * */ private static final long serialVersionUID = 6666646538881797793L; private Integer commentid; private Goods goods; private User user; private String comment; private String time;