JSON: Property 'xxx' has no getter method in class 'class xxx'
JSONArray jsonArr = new JSONArray(); jsonArr.add(new Student("name"));
对于上述内容,错误是出在第二行。
net.sf.json.JSONException: java.lang.NoSuchMethodException: Property 'name' has no getter method in class 'Student'
它要求bean 也就是 Student 这个类必须是 public class 的。
参考自: http://blog.csdn.net/itmyhome/article/details/7010528
NOTE:
需要以下类库支持
- jakarta commons-lang 2.5
- jakarta commons-beanutils 1.8.0
- jakarta commons-collections 3.2.1
- jakarta commons-logging 1.1.1
- ezmorph 1.0.6