实体Menu有两个属性
private Set roleMenus = new HashSet(0);
private Set newsMenus = new HashSet(0);
因此在查询出List<Menu> menuList,并转换成json数据时,
这两个属性互相引用造成了死循环,于是报错:There is a cycle in the hierarchy!
解决办法:
JsonConfig config = new JsonConfig();
config.setExcludes(new String[]{"roleMenus","newsMenus"();
String str = JSONArray.fromObject(menuList,config).toString();