编译都没错就是运行出错,第12行有问题吗?
org.apache.jasper.JasperException: Exception in JSP: /bookstore.jsp:12
9: <%@ include file="head.html"%>
10:
11: <table>
12: <%for(ListIterator iter=bookDB.getBooks().listIterator();iter.hasNext();){
13: BookDetails book=(BookDetails)iter.next();
14: %>
15: <tr>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.lang.NullPointerException database.BookDB.getBooks(BookDB.java:35)
org.apache.jsp.bookstore_jsp._jspService(bookstore_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
------解决方案--------------------java.lang.
NullPointerExceptiondatabase.BookDB.getBooks(BookDB.java:35)
检查你自己的Java代码BookDB.java第35行,这里
空指针了。
黄线可以暂不管,是因为你没有用泛型。
------解决方案--------------------bookDB.getBooks()
空指针异常,
可能bookDB == null
也可能bookDB.getBooks() == null
你自己排查一下。。。
------解决方案--------------------bookDB是空指针 ,
java.lang.NullPointerException
database.BookDB.getBooks(BookDB.java:35)
------解决方案--------------------java.lang.ClassCastException: database.BookDetails cannot be cast to java.lang.Comparable
BookDetails 这个类要implements Comparable这个接口的哇