这是一个书后实例,是structs + hibernate的项目,但用到了Spring中的PageListHolder。按理说不该有错,仔细查看了整个传值流程也找不出问题。进入网络商城首页,点击书籍——点击computerbo 然后就出现以下空指针错误:
javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "items" with value "${itemList.pageList}": An error occurred while getting property "pageList" from an instance of class org.springframework.beans.support.PagedListHolder (java.lang.NullPointerException)愿意帮忙的朋友可以把邮箱留下,我会把建表语句和这小项目都发过去。
最后希望大家能告诉我问题所在,谢谢了~~
javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "items" with value "${itemList.pageList}": An error occurred while getting property "pageList" from an instance of class org.springframework.beans.support.PagedListHolder (java.lang.NullPointerException)愿意帮忙的朋友可以把邮箱留下,我会把建表语句和这小项目都发过去。
最后希望大家能告诉我问题所在,谢谢了~~
解决方案 »
- 如何设置<s:datetimepicker> 加载即为展开状态?
- ========在北京找工作,准备中。
- 老问题:Cannot find ActionMappings or ActionFormBeans collection
- 关于jsp,servlet,struts在eclipse
- 一个struts超级棘手的问题,如果有人可以解决的的话,那他一定是个超强人!谢谢各位大虾了!~!!!!
- 怎样将DOM输出为xml格式的字符串
- 请问关于struts1.1中使用多配置文件的问题??
- 请教各位高手一个问题(急!!!!!!!)
- QueryRule怎么用?
- CommonsMultipartResolver上传文件过大时抛出异常后导致响应无法返回
- extjs 缺少对象
- 关于使用JSP开发WAP网站
在category.jsp页面:http://localhost:8088/netshop/shop/viewCategory.do?categoryId=software
点击产品"KingSoft"后跳转至Product.jsp页面:http://localhost:8088/netshop/shop/viewProduct.do?productId=KingSoft
也就是在这个页面出现了相关异常:org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "items" with value "${itemList.pageList}": An error occurred while getting property "pageList" from an instance of class org.springframework.beans.support.PagedListHolder (java.lang.NullPointerException)javax.servlet.ServletException: javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "items" with value "${itemList.pageList}": An error occurred while getting property "pageList" from an instance of class org.springframework.beans.support.PagedListHolder (java.lang.NullPointerException)root cause java.lang.NullPointerException
<tr><td >
<a href="<c:url value="/shop/index.do"/>"><b><font size="2"/><bean:message key="netshop.mainu"/></b></td>
</tr>
</table><p>
<center>
</center>
<table width="80%" border="1" align="center" >
<tr > <td width="47%"><b><bean:message key="netshop.productid"/></b></td> <td width="53%"><b><bean:message key="netshop.category"/></b></td> </tr>
<c:forEach var="product" items="${productList.pageList}">
<tr >
<td><b><a href="<c:url value="/shop/viewProduct.do"><c:param name="productId" value="${product.productId}"/></c:url>">
<font color="RED"><c:out value="${product.productId}"/></font>
</a></b></td>
<td><c:out value="${product.name}"/></td>
</tr>
</c:forEach>
<tr><td>
<c:if test="${!productList.firstPage}">
<a href="?page=previous"><font color="white"><B><< <bean:message key="netshop.prepage"/></B></font></a>
</c:if>
<c:if test="${!productList.lastPage}">
<a href="?page=next"><font color="white"><B><bean:message key="netshop.nextpage"/> >></B></font></a>
</c:if>
</td></tr>
</table>
<tr><td >
<a href="<c:url value="/shop/viewCategory.do"><c:param name="categoryId" value="${product.categoryId}"/></c:url>">
<b><font color="BLACK" size="2"><c:out value="${product.name}"/></font></b>
</a>
</td></tr>
</table><p><center>
<b><font size="4"><c:out value="${product.name}"/></font></b>
</center><table width="100%" border="2" align="center" >
<tr > <td><b><bean:message key="netshop.itemid"/></b></td> <td><b><bean:message key="netshop.productid"/></b></td> <td><b><bean:message key="netshop.description"/></b></td> <td><b><bean:message key="netshop.price"/></b></td> <td> </td> </tr>
<c:forEach var="item" items="${itemList.pageList}">
<tr >
<td><b>
<a href="<c:url value="/shop/viewItem.do"><c:param name="itemId" value="${item.itemId}"/></c:url>">
<c:out value="${item.itemId}"/>
</a></b></td>
<td><c:out value="${item.productId}"/></td>
<td>
<c:out value="${item.attribute1}"/>
<c:out value="${item.attribute2}"/>
<c:out value="${product.name}"/>
</td>
<td><fmt:formatNumber value="${item.listPrice}" pattern="$#,##0.00"/></td>
<td><a href="<c:url value="/shop/addItemToCart.do"><c:param name="workingItemId" value="${item.itemId}"/></c:url>">
<bean:message key="netshop.puttocart"/>
</a></td>
</tr>
</c:forEach>
<tr><td>
<c:if test="${!itemList.firstPage}">
<a href="?page=previous"><font color="white"><B><< <bean:message key="netshop.prepage"/></B></font></a>
</c:if>
<c:if test="${!itemList.lastPage}">
<a href="?page=next"><font color="white"><B><bean:message key="netshop.nextpage"/> >></B></font></a>
</c:if>
</td></tr>
</table>
<c:out value="${item.itemId}"/>
</a></我觉得这种代码很烦躁
空指针异常是众多异常中最好调试的异常之一。因为你的这个代码过多,可以删除一些代码,缩小范围。并借助debug查看每一步的运行结果。