org.apache.jasper.JasperException:An exception occurred processing JSP page /Index.jsp at line 4037:%>38:39:43:Stacktrace:\x05org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)\x05org.apache.jasper.servlet.JspS

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 14:08:20
org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/Index.jspatline4037:%>38:39:4

org.apache.jasper.JasperException:An exception occurred processing JSP page /Index.jsp at line 4037:%>38:39:43:Stacktrace:\x05org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)\x05org.apache.jasper.servlet.JspS
org.apache.jasper.JasperException:An exception occurred processing JSP page /Index.jsp at line 40
37:%>
38:
39:
43:
Stacktrace:
\x05org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
\x05org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
\x05org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
\x05org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
\x05javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
\x05com.bjsxt.shopping.util.filter.IPFilter.doFilter(IPFilter.java:31)
root cause
java.lang.NullPointerException
\x05com.bjsxt.shopping.category.CategoryService.getCategories(CategoryService.java:102)
\x05org.apache.jsp.Index_jsp._jspService(Index_jsp.java:95)
\x05org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
\x05javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
\x05org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
\x05org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
\x05org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
\x05javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
\x05com.bjsxt.shopping.util.filter.IPFilter.doFilter(IPFilter.java:31)
如何改呢?

org.apache.jasper.JasperException:An exception occurred processing JSP page /Index.jsp at line 4037:%>38:39:43:Stacktrace:\x05org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)\x05org.apache.jasper.servlet.JspS
教你怎么看异常信息.你给出的信息里不是有一拖吗,先看Stacktrace部分
org.apache开头的,明显不是你的代码.apache的一个jar包.不用管.它报错是因为你传给它的值不是它想要的.javax.servlet.http.HttpServlet.service这个也不是你的代码.com.bjsxt.shopping.util.filter.IPFilter.doFilter这个相对来说可能就跟你的关系最经了.这应该是属于你们老师给的代码里的一部分.
接下来找错.
root cause 中的信息.先找com.bjsxt开头的.为什么,因为com.bjsxt离你最近
OK.你看到了两行最近的.我也看到两行:
com.bjsxt.shopping.category.CategoryService.getCategories(CategoryService.java:102)
com.bjsxt.shopping.util.filter.IPFilter.doFilter(IPFilter.java:31)
来.提示信息时NullPointerException;最熟悉的空指针.
从这两行中选.
然后看你问题题目中提到的:
org.apache.jasper.JasperException:An exception occurred processing JSP page /Index.jsp at line 40
注意,这个是最直观的信息 at line 40
好你又找到了line 40,是:
40:List categories = CategoryService.getInstance().getCategories();
看.跟我们之前揪出来的两行中的一行:
com.bjsxt.shopping.category.CategoryService.getCategories(CategoryService.java:102)
是不是关系最近对吧.
这个时候,你就可以很肯定的告诉自己告诉别人:
是你com.bjsxt.shopping.category包下的CategoryService类的 getCategories方法在你的第40行执行后,返回的结果是null,null当然就报nullpointException了.
你还可以看到
com.bjsxt.shopping.category.CategoryService.getCategories(CategoryService.java:102)
后面括号里的信息.那是提示你在执行getCategories方法时,代码运行到102行出的错.
大功告成.
讲的比你们老师将得还细.开个玩笑.