0
私は、ユーザーのカートに製品を保管するテーブルを持っています。各行には、ユーザーがユーザーのカートから単一の製品を取り除くことを可能にするボタンがあります。ここで私のhtmlのコードスニペットです。htmlの表から行の単一のデータを返す方法は?
<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がすべて返されます。ここにコントローラのコードスニペットがあります。
@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";
}