List转换成JSON对象
1、具体错误如下
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
at net.sf.json.JSONObject.<init>(JSONObject.java:1603)
at net.sf.json.util.CycleDetectionStrategy.<clinit>(CycleDetectionStrategy.java:37)
at net.sf.json.JsonConfig.<clinit>(JsonConfig.java:65)
at net.sf.json.JSONArray.addAll(JSONArray.java:1255)
at com.you.file.upload.util.ListToJSON.main(ListToJSON.java:49)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.ListOrderedMap
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
at net.sf.json.JSONObject.<init>(JSONObject.java:1603)
at net.sf.json.util.CycleDetectionStrategy.<clinit>(CycleDetectionStrategy.java:37)
at net.sf.json.JsonConfig.<clinit>(JsonConfig.java:65)
at net.sf.json.JSONArray.addAll(JSONArray.java:1255)
at com.you.file.upload.util.ListToJSON.main(ListToJSON.java:49)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.ListOrderedMap
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
2、错误原因
lib目录中未导入commons-collections-3.1.jar
3、解决办法
向WEB-INF目录下的lib目录导入commons-collections-3.1.jar