There is a cycle in the hierarchy!List res = resourceService.findAll();JSONArray datalist = JSONArray.fromObject(res);//这里报错there is a cycle in the hierarchy用网上提供的方法不好使下面是Resource属性private Integer id;\x05privat

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 22:26:01
Thereisacycleinthehierarchy!Listres=resourceService.findAll();JSONArraydatalist=JSONArray.fromObject

There is a cycle in the hierarchy!List res = resourceService.findAll();JSONArray datalist = JSONArray.fromObject(res);//这里报错there is a cycle in the hierarchy用网上提供的方法不好使下面是Resource属性private Integer id;\x05privat
There is a cycle in the hierarchy!
List res = resourceService.findAll();
JSONArray datalist = JSONArray.fromObject(res);//这里报错there is a cycle in the hierarchy
用网上提供的方法不好使
下面是Resource属性
private Integer id;
\x05private String title;
\x05private String description;
\x05private Set roles = new HashSet();
Resource和Role有多对多的关系
Role的属性
private Integer id;
\x05private String roleName;
\x05private Set res = new HashSet();

There is a cycle in the hierarchy!List res = resourceService.findAll();JSONArray datalist = JSONArray.fromObject(res);//这里报错there is a cycle in the hierarchy用网上提供的方法不好使下面是Resource属性private Integer id;\x05privat
有把有关联的属性放到json数组中就可以了.因为Resource的json数组中有roles数组,而且roles的数组元素中又有Resource数组,死循环了.用JSONConfig把roles去除就可以了.