??560
2015-05-15 13:45
采纳率: 63.6%
浏览 2.5k
已采纳

求助!jsp 中substring报错

String intime=request.getParameter("d11");//从文本框中获得的日期,这是从
my97Date控件中获得的值,一开始时为空,点击查询按钮后才会有值
String intime3=intime.substring(5, 8);

出现下列错误:
type Exception report

message An exception occurred processing JSP page /ShowRoom2.jsp at line 80

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /ShowRoom2.jsp at line 80

77:
78: <%
79: String intime=request.getParameter("d11");
80: String intime3=intime.substring(5, 8);
81: //if(substring(intime,1,4))
82: //if(intime.substring(0, 4).equals("6"))
83: out.println("杞寲鐨勬椂闂达細"+intime3);

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

root cause

java.lang.NullPointerException
org.apache.jsp.ShowRoom2_jsp._jspService(ShowRoom2_jsp.java:153)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.52 logs.
我自己分析了一下原因是第80行出现了空指针,但是我的intime是有值的(“2015-06-15”),就是使用substring报错
有人知道怎么回事吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题