json字符串转java对象 出错
JSONObjectjsonobject=JSONObject.fromObject(str);maina=null;a=(main)JSONObject.toBean(...
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 展开
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 展开
2个回答
2017-06-27
展开全部
项目缺少jar包。
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询