0
下面每次画廊只增加1个产品我点击添加到购物车,我希望它通过ID为所选的特定项目从<foreach tag>
问题: 1 - 该servlet加1个产品加入购物车(第一个)和URL看起来像这样: 本地.../DisplayCart的productId = 01 &的productId = 02 &行动= addtocart
<form action="/DisplayCart">
<c:forEach var="product" items="${products}">
<tr>
<td>${product.name}</td>
<td>${product.description}</td>
<td>${product.price}</td>
<td></td>
<td>
<input type="hidden" name="productId" value="${product.id}">
<input type="submit" name="action" value="addtocart"></td>
</tr>
</c:forEach>
<form action="<c:url value='/DisplayCart'/>">
<table>
<c:forEach var="item" items="${cart.items}">
<tr>
<td>
<input type="hidden" name="productId" value="${item.product.id}">
<input type="text" size="2" name="quantity" value="${item.quantity}">
<input type="submit" value="Update">
</td>
<td>${item.product.name}</td>
<td>${item.product.description}</td>
<td>${item.product.price}</td>
<td><input type="submit" name="removeButton" value="Remove"> </td>
</tr>
</table>
</form>
</c:forEach>
没有其实我是想用户是能够选择任何这个循环基本上从数据库中列出的项目..无论如何感谢 – TrackmeifYouCan