【发布时间】:2016-10-13 05:17:14
【问题描述】:
我有一张表格,将产品存储在用户的购物车中。每行都有一个按钮,使用户能够从用户的购物车中删除单个产品。这是我的html的代码sn-p。
<form action="${pageContext.request.contextPath}/customer/removeProduct" method="post">
<input type="hidden" name="page" value="${page}">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<c:forEach items="${productsInCart}" var="product"
varStatus="status">
<input type="hidden" class="form-control" name="upc"
value="${product.getUpc()}">
<tr class="warning">
<td>${product.getName()}</td>
<td>${product.getQuantity()}</td>
<td style="color: green;">₱ ${product.getTotal()}</td>
<td><input type="submit" class="btn btn-warning btn-xs"
value="Remove from cart"></td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
这是输出。
我想要获取的值是存储在隐藏输入类型字段中的产品的 UPC。但是,当单击“从购物车中删除”按钮时,它会返回购物车中产品的所有 UPC。这是控制器的代码sn-p。
@RequestMapping(value="/customer/removeProduct", method=RequestMethod.POST)
public String removeProduct(@RequestParam(value = "upc") String upc, HttpServletRequest request){
System.out.println(upc);
// customerService.removeProductInCart(customer.getCustomer(request).getCartId(), upc);
return "customer_home";
}
【问题讨论】:
标签: java html jsp spring-mvc jstl