我在我的 SERVLET 中创建了一个哈希图,如下所示:
int productId = Integer.parseInt(request.getParameter("productId"));
HashMap cartList = new HashMap();
Cart item = new Cart(productId, productName, price, quantity);
cartList.put(productId, item);
但我收到以下错误:
org.apache.jasper.JasperException:javax.el.PropertyNotFoundException:类“java.util.HashMap$Entry”没有属性“productId”。
这是什么意思?我该如何解决我的错误?
编辑:这是我的 JSP
<c:forEach var="cart" items="${cartList}">
${cart.productId}
${cart.productName}
<form method="POST" action="ShoppingCartUpdate">
<input type="submit" value ="Update" class="loginButton" name="Update">
</form>
<form method="POST" action=""ShoppingCartRemove">
<input type="submit" value ="Remove" class="loginButton" name="Delete">
</form>
</c:forEach>