List转换成JSON对象
1、具体错误如下
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:227) at net.sf.json.JSONArray._processValue(JSONArray.java:2514) at net.sf.json.JSONArray.processValue(JSONArray.java:2539) at net.sf.json.JSONArray.addValue(JSONArray.java:2526) at net.sf.json.JSONArray.element(JSONArray.java:1725) at net.sf.json.JSONArray.addAll(JSONArray.java:1263) 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.beanutils.DynaBean 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) ... 8 more
2、错误原因
lib目录下未导入commons-beanutils-1.8.0.jar
3、解决办法
向WEB-INF目录下的lib目录导入commons-beanutils-1.8.0.jar