在网上看到了很多方法 使用 jsonconfig 过滤掉属性 还是不行
public void plist() {
// TODO Auto-generated method stub
List<Province> plist=pcd.plist();
JsonConfig config=new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
// TODO Auto-generated method stub
if(arg1.equals("cities")||arg1.equals("userinfos")){
return true;
}
return false;
}
});
JSONArray json=JSONArray.fromObject(plist,config);
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("utf-8");
try {
response.getWriter().write(json.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void plist() {
// TODO Auto-generated method stub
List<Province> plist=pcd.plist();
JsonConfig config=new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
// TODO Auto-generated method stub
if(arg1.equals("cities")||arg1.equals("userinfos")){
return true;
}
return false;
}
});
JSONArray json=JSONArray.fromObject(plist,config);
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("utf-8");
try {
response.getWriter().write(json.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
解决方案 »
- JSP问题 index.jsp使用meta 页面都跳转不过去
- html+jsp+jquery 这样的前端架构有什么样的优缺点啊?适合大型局域网的网站架构么?安全性能如何?
- wap2.0,怎么显示天气预报
- 新手提问: 如何进行时间换算
- 初学struts,请教连接sql Server数据库的方法(越简单越好,呵呵)
- 请教一个关于sqlserver数据类型转换的问题,请各位多帮忙!!!
- 一个非常见单的问题50分得回报 连接Microsoft SQL Server数据库
- 关于调用input中的value值(太弱了)
- 请swing高手最后一击,jTree如何根据数据生成树
- JSP和XML共同使用字符集问题
- 新手一枚,遇到问题请帮帮忙指教下
- Struts2页面跳转了但是页面显示不出来The requested resource (/success.jsp) is not available
<class name="com.lee.bbs.entity.Province" table="PROVINCE" schema="BBS">
<id name="pid" type="java.lang.Integer">
<column name="PID" precision="0" />
<generator class="assigned" />
</id>
<property name="pname" type="java.lang.String">
<column name="PNAME" length="40" not-null="true" />
</property>
<set name="cities" inverse="true" lazy="false">
<key>
<column name="PID" precision="0" not-null="true" />
</key>
<one-to-many class="com.lee.bbs.entity.City" />
</set>
<set name="userInfos" inverse="true" lazy="false">
<key>
<column name="PID" precision="0" not-null="true" />
</key>
<one-to-many class="com.lee.bbs.entity.UserInfo" />
</set>
</class>
</hibernate-mapping>
at net.sf.json.util.CycleDetectionStrategy$StrictCycleDetectionStrategy.handleRepeatedReferenceAsObject(CycleDetectionStrategy.java:97)
at net.sf.json.JSONObject._fromBean(JSONObject.java:657)
at net.sf.json.JSONObject.fromObject(JSONObject.java:172)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274)
at net.sf.json.JSONArray._processValue(JSONArray.java:2513)
at net.sf.json.JSONArray.processValue(JSONArray.java:2538)
at net.sf.json.JSONArray.addValue(JSONArray.java:2525)
at net.sf.json.JSONArray._fromCollection(JSONArray.java:1056)
at net.sf.json.JSONArray.fromObject(JSONArray.java:123)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:240)
at net.sf.json.JSONObject._processValue(JSONObject.java:2655)
at net.sf.json.JSONObject.processValue(JSONObject.java:2721)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2736)
at net.sf.json.JSONObject.setValue(JSONObject.java:1424)
at net.sf.json.JSONObject.defaultBeanProcessing(JSONObject.java:765)
at net.sf.json.JSONObject._fromBean(JSONObject.java:699)
at net.sf.json.JSONObject.fromObject(JSONObject.java:172)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274)
at net.sf.json.JSONObject._processValue(JSONObject.java:2655)
at net.sf.json.JSONObject.processValue(JSONObject.java:2721)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2736)
at net.sf.json.JSONObject.setValue(JSONObject.java:1424)
at net.sf.json.JSONObject.defaultBeanProcessing(JSONObject.java:765)
at net.sf.json.JSONObject._fromBean(JSONObject.java:699)
at net.sf.json.JSONObject.fromObject(JSONObject.java:172)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274)
at net.sf.json.JSONArray._processValue(JSONArray.java:2513)
at net.sf.json.JSONArray.processValue(JSONArray.java:2538)
at net.sf.json.JSONArray.addValue(JSONArray.java:2525)
at net.sf.json.JSONArray._fromCollection(JSONArray.java:1056)
at net.sf.json.JSONArray.fromObject(JSONArray.java:123)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:240)
at net.sf.json.JSONObject._processValue(JSONObject.java:2655)
at net.sf.json.JSONObject.processValue(JSONObject.java:2721)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2736)
at net.sf.json.JSONObject.setValue(JSONObject.java:1424)
at net.sf.json.JSONObject.defaultBeanProcessing(JSONObject.java:765)
at net.sf.json.JSONObject._fromBean(JSONObject.java:699)
at net.sf.json.JSONObject.fromObject(JSONObject.java:172)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274)
at net.sf.json.JSONArray._processValue(JSONArray.java:2513)
at net.sf.json.JSONArray.processValue(JSONArray.java:2538)
at net.sf.json.JSONArray.addValue(JSONArray.java:2525)
at net.sf.json.JSONArray._fromCollection(JSONArray.java:1056)
at net.sf.json.JSONArray.fromObject(JSONArray.java:123)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:240)
at net.sf.json.JSONObject._processValue(JSONObject.java:2655)
at net.sf.json.JSONObject.processValue(JSONObject.java:2721)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2736)
at net.sf.json.JSONObject.setValue(JSONObject.java:1424)
at net.sf.json.JSONObject.defaultBeanProcessing(JSONObject.java:765)
at net.sf.json.JSONObject._fromBean(JSONObject.java:699)
at net.sf.json.JSONObject.fromObject(JSONObject.java:172)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274)
at net.sf.json.JSONArray._processValue(JSONArray.java:2513)
at net.sf.json.JSONArray.processValue(JSONArray.java:2538)
at net.sf.json.JSONArray.addValue(JSONArray.java:2525)
at net.sf.json.JSONArray._fromCollection(JSONArray.java:1056)