Servlet代码段:
// check/get session
HttpSession session = request.getSession();
ArrayList<LineItem> transactions = (ArrayList<LineItem>)session.getAttribute("transactions");
.....
// set session
session.setAttribute("transactions", transactions);
JSP代码段:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
.....
<c:forEach var="item" transactions="${transactions}">
<tr>
<td>${item.action}</td>
<td>${item.product.getCode}</td>
<td>${item.product.getArtist}</td>
<td>${item.product.getTitle}</td>
<td>${item.product.getCategory}</td>
<td>${item.product.getDescription}</td>
<td>${item.product.getPriceCurrency}</td>
</tr>
</c:forEach>
例外:
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Maintenance] threw exception [/product_audit.jsp (line: 52, column: 4) Attribute transactions invalid for tag forEach according to TLD] with root cause
org.apache.jasper.JasperException: /product_audit.jsp (line: 52, column: 4) Attribute transactions invalid for tag forEach according to TLD
我正在使用JSTL 1.0(在清单中声明并验证.jar文件)。有什么建议吗?
答案 0 :(得分:1)
错误消息很明确:
根据TLD
,标签forEach的属性事务无效
问题在于:
<c:forEach var="item" transactions="${transactions}">
<!-- ^ there is no such attribute -->
transactions
改变items
:
<c:forEach var="item" items="${transactions}">