解决hibernate采用双向关联时生成JSON出错的问题
由于hibernate是采用双向关联,所以在生成JSON对象时会引起嵌套而抛出net.sf.json.JSONException: There is a cycle in the hierarchy异常。
解决办法
JsonConfig jsonConfig=new JsonConfig();jsonConfig.setIgnoreDefaultExcludes(false); jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);