[color=red]控制台出现如下循环异常:[/color]
[color=red]今天做显示商品评论功能 使用springmvc ajax加载,查询出来的数据转换成json时出现了死循环,如下:[/color]
[quote]
[{"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":"毕节特产",
[/quote]
[color=red]查询评论表 而评论表和商品表是多对一的关系,商品表和分类表.地区表多对一的关系,[/color]
[color=orange]死循环原因:json无法对comments表的goods属性进行转换[/color]
[color=red]解决办法:[/color]
[color=orange]在comments实体类上加注解@JsonIgnoreProperties(value={"goods"})[/color]
:D
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)
[color=red]今天做显示商品评论功能 使用springmvc ajax加载,查询出来的数据转换成json时出现了死循环,如下:[/color]
[quote]
[{"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":"毕节特产",
[/quote]
[color=red]查询评论表 而评论表和商品表是多对一的关系,商品表和分类表.地区表多对一的关系,[/color]
[color=orange]死循环原因:json无法对comments表的goods属性进行转换[/color]
[color=red]解决办法:[/color]
[color=orange]在comments实体类上加注解@JsonIgnoreProperties(value={"goods"})[/color]
@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;
:D