JSONObject jsonobject = JSONObject.fromObject(str);
main a = null;
a = (main)JSONObject.toBean(jsonobject, main.class);
main是我的java类。
字符串我在java里写就能正常工作。但通过http请求进来的字符串就不行,输出后跟Java里写的相同却依旧报错,找不到原因. 错误:
Servlet.service() for servlet [example] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: net/sf/json/JSONObject] with root cause
java.lang.NoClassDefFoundError: net/sf/json/JSONObject
项目缺少jar包。
<dependency>