net.sf.json出现的问题,实在解决不了啊

cy320h 2019-04-25 07:20:35
信息: Property 'jianjie' of class com.object.Sz has no read method. SKIPPED
四月 25, 2019 7:05:17 下午 net.sf.json.JSONObject defaultBeanProcessing
信息: Property 'mode' of class com.object.Sz has no read method. SKIPPED
四月 25, 2019 7:05:17 下午 net.sf.json.JSONObject defaultBeanProcessing
信息: Property 'official' of class com.object.Sz has no read method. SKIPPED
四月 25, 2019 7:05:17 下午 net.sf.json.JSONObject defaultBeanProcessing
信息: Property 'postcode' of class com.object.Sz has no read method. SKIPPED
四月 25, 2019 7:05:17 下午 net.sf.json.JSONObject defaultBeanProcessing
信息: Property 'productname' of class com.object.Sz has no read method. SKIPPED



我的大概代码


List<Sz> array = new ArrayList<Sz>();
JSONArray jsonArray = new JSONArray();
String v1 = request.getParameter("value1");
try {
Connection newcon = conn.getcon();
Statement state = newcon.createStatement();
String sql = "select * from product,(select d.id from (select *from kind where p_id=(select id from kind where kindname='"+v1+"'))as c,kind d where c.id=d.p_id)as e where e.id=product.thing_pid";
ResultSet rs = state.executeQuery(sql);
while(rs.next())
{
Sz s1 = new Sz(rs.getString("productname"), rs.getString("use"), rs.getString("factory"), rs.getString("official"), rs.getInt("postcode"),rs.getInt("telphone"), rs.getString("jianjie"), rs.getString("mode"));
//System.out.println(name + "\t" + id);
array.add(s1);
JSONObject object = JSONObject.fromObject(s1);
jsonArray.add(object);
}
rs.close();
newcon.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//jsonArray = JSONArray.fromObject(array);
System.out.println(jsonArray);



package com.object;

public class Sz {
public String productname;
public String mode;
public String use;
public Integer telphone;
public String jianjie;
public String factory;
public String official;
public Integer postcode;

public Sz(String productname,String use,String factory,String official,Integer postcode,Integer telphone,String jianjie,String mode){
this.productname = productname;
this.use = use;
this.factory = factory;
this.official = official;
this.postcode = postcode;
this.telphone = telphone;
this.jianjie = jianjie;
this.mode = mode;
}
...全文
1042 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cy320h 2019-04-26
  • 打赏
  • 举报
回复
谢谢大家的回复 ,错误处理了
getdate 2019-04-26
  • 打赏
  • 举报
回复
Sz 类中 没有属性的get,set 方法; 还有,要注意,Sz 中的属性,应该是他自己私有的;
十八道胡同 2019-04-25
  • 打赏
  • 举报
回复
你的sz里面的变量都弄成私有,然后用get set函数来访问私有变量 private String jianjie; public GetJianJie() { return jianjie;} public SetJianJie(String s) {jianjie=s;}

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧