每次我点击添加到购物车时,下面的图库,我希望它传递特定选定项目的 ID
问题:1-servlet 将 1 个产品添加到购物车(第一个),并且 url 如下所示:local.../DisplayCart?productId=01&productId=02&action=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>