使用日期时的JSP JasperException

时间:2012-12-05 08:38:59

标签: java jsp

我正在尝试提交一个数字作为输入,我收到了这个错误。我不知道出了什么问题!请提供您的见解

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

11: int id=Integer.parseInt(request.getParameter("rowId").trim());
12: int membid=0;
13: String[] values=request.getParameterValues("memb");
14: int len=values.length;
15: for(int i=0;i<len;i++)
16: {
17:     if(!values[i].equalsIgnoreCase(""))


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.NullPointerException
    org.apache.jsp.SubmitMovie_jsp._jspService(SubmitMovie_jsp.java:67)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

1 个答案:

答案 0 :(得分:0)

从堆栈跟踪中得到NullPointerException

11: int id=Integer.parseInt(request.getParameter("rowId").trim());
12: int membid=0;
13: String[] values=request.getParameterValues("memb");
14: int len=values.length;
15: for(int i=0;i<len;i++)
16: {
17:     if(!values[i].equalsIgnoreCase(""))

检查一些事情

  1. 字符串数组values并非您尝试访问values.length
  2. rowId始终不为null,非空且出现在参数中,因为您要解析它以转换为Integer