JSONArray().fromObject(); 出現org.apache.catalina.core.StandardWrapperValve invoke錯誤的解決辦法

servlet:html

 1 public void service(HttpServletRequest request, HttpServletResponse response)  2     throws ServletException, IOException {  3 
 4         response.setContentType("text/html");  5         response.setCharacterEncoding("utf-8");  6 
 7         IBllFrame interfaceOfBllFrame=new BllFrame();  8         JSONArray json = null;  9 
10         List<HashMap<String, Object>> result=interfaceOfBllFrame.GetStationPlace(); 11         System.out.println("GetStationPlace:" + result.get(1).toString()); 12         try { 13             System.out.println("haha begin:" + json); 14             
15             json=new JSONArray().fromObject(result);//上述錯誤出如今此句 16             System.out.println("haha success:" + json); 17  } 18         catch (Exception e){ 19  e.printStackTrace(); 20  } 21 
22         System.out.println("Servlet---StationPlace"+json); 23         PrintWriter out = response.getWriter(); 24  out.println(json); 25  out.flush(); 26  out.close(); 27     }

控制器中輸出結果以下:java

下面爲上圖中的信息:apache

GetStationPlace:{StationId=10002, Stationlon=29.90592, Stationlat=121.525976}
haha begin:null
二月 29, 2016 10:37:46 上午 org.apache.catalina.core.StandardWrapperValve invoke
嚴重: Servlet.service() for servlet [GetStationPlaceServlet] in context with path [/BicycleDataSystem] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: net.sf.json.JSONArray
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1722)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573)json

 

原先commons-beanutils.jar 、commons-collections.jar、commons-lang.jar、 commons-logging.jar、ezmorph.jar、json-lib.jar這些包放在lib-》json文件夾下以下:app

後來commons-beanutils.jar 、commons-collections.jar、commons-lang.jar、 commons-logging.jar、ezmorph.jar、json-lib.jar直接放到lib文件夾下,以下:spa

注意:就是說將commons-beanutils.jar 、commons-collections.jar、commons-lang.jar、 commons-logging.jar、ezmorph.jar、json-lib.jar這些包必定要直接放在lib文件夾下,不然會出現org.apache.catalina.core.StandardWrapperValve invoke錯誤。code

JSONArray().fromObject須要以下jar包:commons-beanutils.jar 、commons-collections.jar、commons-lang.jar、 commons-logging.jar、ezmorph.jar、json-lib.jar

下載地址:http://pan.baidu.com/s/1pJUmBQNhtm

相關文獻:http://greenboy1.iteye.com/blog/1046125blog

相關文章
相關標籤/搜索