提示的錯誤是:
嚴重: Servlet.service() for servlet Shopping threw exception
java.lang.NullPointerException
at cn.itcast.Shopping.doGet(Shopping.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
代碼如下
一開始打完之後是可以正常運行的,但當我去打另外一個跳轉的Servlet打完之後就出錯誤了,另一個Servlet的代碼是這樣的
![圖片說明
at cn.itcast.Shopping.doGet(Shopping.java:45)
這句話,告訴你,shopping類45行,沒有取到值,然後你有個習慣非常不好,在java類左邊上,沒有行數標記,你最好設置一下
我都不知道45行是啥,而且好多類都在shopping這一個類裡面了。。。。你應該這樣反推,然後確定是哪裡的問題,