Eclipse未定义属性名中的java JSP/JSTL错误
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文件)。有什么建议吗
# 1 楼答案
错误信息很清楚:
问题在于:
将
transactions
更改为items
: