//设置json过滤主外键,防止出现死循环there is a cycle in the hierarchy! JsonConfig config = new JsonConfig(); config.setJsonPropertyFilter(new PropertyFilter(){//过滤属性 //其中houses,district就是我们要过滤的字段,也就是JavaBean中的属性名 public boolean apply(Object arg0, String name, Object arg2) { if(name.equals("houses")||name.equals("district")){ return true; } return false; } }); //在转换的时候加个config JSONArray jsarr = JSONArray.fromObject(streetList,config); request.setAttribute("jsarr", jsarr); }
这个异常,是由于,json在转换数据的时候,能够检测出要转换的属性之间存在着主外键关系,特别是hibernate在操作数据的时候,造成了死循环,解决办法,就是用JsonConfig提供的一个过滤属性的方法,实现里面的apply的方法,然后将要过滤的属性进行判断。这样就可以解决这个问题了。
相关推荐
如果需要解析的数据间存在级联关系,而互相嵌套引用,在hibernate中极容易嵌套而抛出net.sf.json.JSONException: There is a cycle in the hierarchy异常。
并且对Dao和Service进行了封装,内含.jar包,并且解决了一对多双向关联的could not initialize proxy - no Session错误,同时解决了……invoked on net.sf.json.JSONException: There is a cycle in the hierarchy!...
解决这个启动 View Hierarchy时的这个bug: hierarchy viewer unable to debug device
Test of consistency is critical for the AHP methodology. When a pairwise comparison matrix (PCM) fails the consistency test, the decision maker (DM) needs to make revisions. The state of the art ...
To develop a solid understanding of a data structure requires three things: First, you must learn how the information is arranged in the memory of the computer. Second, you must become familiar with ...
sql server 2014 JSON解析到表函数 CREATE FUNCTION [dbo].[parseJSON]( @JSON NVARCHAR(MAX)) RETURNS @hierarchy TABLE ( element_id INT IDENTITY(1, 1) NOT NULL, ...
the best way to understand how computers work is to build one from scratch, and this textbook leads students through twelve chapters and projects that gradually build a basic hardware platform and a ...
* updated a polygon object: now the polygon toolbar is displayed not near to the object, but in the main toolbar and in ribbon; polygon modes are changed, new modes allow editing and adding curves > ...
the cases in which there exists relationship between the ob- jects to be ranked, despite of the fact that such situations are very common in practice. For example, in web search, given a query certain...
A secondary goal of the book is to present mathematical tools just in time. Analysis techniques and proofs are presented as needed and in the proper context. In the past when the topics in this book ...
Because this work is the rst attempt, combined with the author’s experience and knowledge being limited, if there is any improper place, please contact us. Contact method: E-mail: lfzh@suda.edu.cn,
Even when the actual handling differs, there is still some commonality. Hierarchical state machine design captures the commonality by organizing the states as a hierarchy. The states at the higher ...
The Essential Qt 3.3 Class Hierarchy
本实例使用的是CXF框架通过main方法来进行发布WebService
An intent lock indicates that SQL Server wants to acquire a shared (S) lock or exclusive (X) lock on some of the resources lower down in the hierarchy. For example, a shared intent lock placed at the ...
The Application of AHP+LP in the Evaluation and Selection of Suppliers,BAI He-song,,This paper introduces the Supplier Relationship Management and the evaluation and selection of suppliers....
This is a book about computer organization and architecture. It focuses on the function and design of the various components necessary to process information digitally. We present computing systems as...