首页 > 代码库 > Servlet.service() for servlet UserServlet threw exception java.lang.NullPointerException 空指针异常
Servlet.service() for servlet UserServlet threw exception java.lang.NullPointerException 空指针异常
错误付现:
严重: Servlet.service() for servlet UserServlet threw exception
java.lang.NullPointerException
at com.liuyang.servlet.UserServlet.doGet(UserServlet.java:17)
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.valves.AccessLogValve.invoke(AccessLogValve.java:615)
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:612)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
at java.lang.Thread.run(Thread.java:662)
这个错误是我的前端界面输入的值无法传递到后台,所以后台无法获取.
代码定位
到了这行,但是这行没有错误,那么就找跟它相关的代码,传递的值是username的值,所以找有关username的语句,后端的代码在编译器未报错,说明错误不在后端
所以去前端找问题.
最后发现是
这里出错了,不是$而是&符号所以导致值无法传递.
Servlet.service() for servlet UserServlet threw exception java.lang.NullPointerException 空指针异常