第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

servlet處理json遇見錯(cuò)誤

servlet處理json遇見錯(cuò)誤

qq_蝶戀花_9 2017-12-04 19:19:57
package?servlet; import?java.io.IOException; import?java.io.PrintWriter; import?javax.servlet.ServletException; import?javax.servlet.annotation.WebServlet; import?javax.servlet.http.HttpServlet; import?javax.servlet.http.HttpServletRequest; import?javax.servlet.http.HttpServletResponse; import?javax.servlet.http.HttpSession; import?net.sf.json.JSONObject; import?net.sf.json.util.JSONTokener; @WebServlet("/JsonServlet") public?class?JsonServlet?extends?HttpServlet?{ private?static?final?long?serialVersionUID?=?1L; ????public?JsonServlet()?{ ????????super(); ????} protected?void?doGet(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{ response.setContentType("text/html"); PrintWriter?out?=?response.getWriter(); Student?stu=new?Student(); try{ JSONObject?jsonObject=new?JSONObject(); jsonObject.put("id","1"); jsonObject.put("name","劉繼紅"); jsonObject.put("age","30"); String?json=jsonObject.toString(); JSONTokener?jsonTokener=new?JSONTokener(json); JSONObject?jo=(JSONObject)?jsonTokener.nextValue(); stu.setId(jo.getString("id")); stu.setName(jo.getString("name")); stu.setAge(jo.getString("age")); HttpSession?session=request.getSession(); response.sendRedirect("ajax.jsp"); }catch(Exception?e){ e.printStackTrace(); } } protected?void?doPost(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{ doGet(request,?response); } }<%@?page?language="java"?import="java.util.*"?pageEncoding="ISO-8859-1"?import="servlet.Student"%> <% String?path?=?request.getContextPath(); String?basePath?=?request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"> <html> ??<head> ????<base?href="<%=basePath%>"> ???? ????<title>My?JSP?'ajax.jsp'?starting?page</title> ???? <meta?http-equiv="pragma"?content="no-cache"> <meta?http-equiv="cache-control"?content="no-cache"> <meta?http-equiv="expires"?content="0">???? <meta?http-equiv="keywords"?content="keyword1,keyword2,keyword3"> <meta?http-equiv="description"?content="This?is?my?page"> <!-- <link?rel="stylesheet"?type="text/css"?href="styles.css"> --> ??</head> ?? ??<body> ????<% ???? Student?stu=new?Student(); ???? stu=(Student)request.getSession(); ???? out.println(stu.age); ?????%> ??</body> </html>HTTP?Status?500?-?Servlet?execution?threw?an?exception type?Exception?report message?Servlet?execution?threw?an?exception description?The?server?encountered?an?internal?error?that?prevented?it?from?fulfilling?this?request. exception javax.servlet.ServletException:?Servlet?execution?threw?an?exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) root?cause java.lang.NoClassDefFoundError:?org/apache/commons/lang/exception/NestableRuntimeException java.lang.ClassLoader.defineClass1(Native?Method) java.lang.ClassLoader.defineClass(ClassLoader.java:763) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2267) org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:803) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1244) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109) servlet.JsonServlet.doGet(JsonServlet.java:26) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) root?cause java.lang.ClassNotFoundException:?org.apache.commons.lang.exception.NestableRuntimeException org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109) java.lang.ClassLoader.defineClass1(Native?Method) java.lang.ClassLoader.defineClass(ClassLoader.java:763) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2267) org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:803) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1244) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109) servlet.JsonServlet.doGet(JsonServlet.java:26) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) note?The?full?stack?trace?of?the?root?cause?is?available?in?the?Apache?Tomcat/9.0.0.M17?logs. Apache?Tomcat/9.0.0.M17
查看完整描述

2 回答

已采納
?
cxxyjsj

TA貢獻(xiàn)119條經(jīng)驗(yàn) 獲得超22個(gè)贊

應(yīng)該是少json-lib依賴的jar包吧, commons-lang.jar

查看完整回答
反對(duì) 回復(fù) 2017-12-06
  • 2 回答
  • 0 關(guān)注
  • 1732 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)