问答详情
源自:1-11 Servlet获取表单数据

空指针异常

和老师代码一样,为什么会报空指针异常。完全按照老师的步骤来的,一个字一个字的打

提问者:空指针异常null 2016-11-17 19:56

个回答

  • 韶关hotel
    2016-11-17 23:35:39

    在servlet类中格式化birthday的时候有没有中文呀?不然我也不知道呢;没代码/流泪

  • 韶关hotel
    2016-11-17 21:27:46

    http://img.mukewang.com/582db03000011d3b02300175.jpg你js Floder添加有没有错误先?

  • 黑山头山大王
    2016-11-17 21:22:33

    at servlet.RegServlet.doPost(RegServlet.java:111)

    看一下这一行的代码

  • 空指针异常null
    2016-11-17 20:58:00

    十一月 17, 2016 8:56:50 下午 org.apache.catalina.startup.Catalina start

    信息: Server startup in 4807 ms

    asdf

    asd

    Male

    asdf

    Wed Nov 02 00:00:00 CST 2016

    十一月 17, 2016 8:57:19 下午 org.apache.catalina.core.ApplicationDispatcher invoke

    严重: Servlet.service() for servlet jsp threw exception

    java.lang.NullPointerException

    at java.util.Calendar.setTime(Calendar.java:1106)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:955)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:948)

    at java.text.DateFormat.format(DateFormat.java:336)

    at org.apache.jsp.userinfo_jsp._jspService(userinfo_jsp.java:168)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)

    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)

    at servlet.RegServlet.doPost(RegServlet.java:111)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)

    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)

    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Thread.java:745)

    org.apache.jasper.JasperException: java.lang.NullPointerException

    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:561)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)

    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)

    at servlet.RegServlet.doPost(RegServlet.java:111)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)

    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)

    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Thread.java:745)

    Caused by: java.lang.NullPointerException

    at java.util.Calendar.setTime(Calendar.java:1106)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:955)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:948)

    at java.text.DateFormat.format(DateFormat.java:336)

    at org.apache.jsp.userinfo_jsp._jspService(userinfo_jsp.java:168)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)

    ... 36 more


  • 黑山头山大王
    2016-11-17 20:32:53

    可能是获取日期那里为空,那是个JS控件,webContent下面有一个js的文件夹

    把报错信息贴上来看看