问题描述
- 求问 java为什么空指针异常
-
type Exception reportmessage
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /select.jsp:36
33:
鐢佃瘽
34:
35: <%
36: for(int i = 0;i < rsList.size();i++){
37: Map rsMap = rsList.get(i);
38: System.out.println("椹?笂瑕佸惊鐜?簡");
39: %>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)root cause
java.lang.NullPointerException
org.apache.jsp.select_jsp._jspService(select_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
解决方案
rsList为null吧,可以在for循环前打句日志看看。
解决方案二:
Java空指针异常
java中的空指针异常处理
java异常处理之空指针异常
解决方案三:
是不是rsList里没内容或者下标错误了?
解决方案四:
空指针异常,一般都是无效的引用。