JSP--オンラインショッピングモール->カートショッピング項目の数を修正

1796 ワード

Buy.jsp
//          
    if (action != null && action.equals("update")) {
        Iterator<CartItem> it = c.getItems().iterator();
        while (it.hasNext()) {
            CartItem item = it.next();
            int count = Integer.parseInt(request.getParameter("p"
                    + item.getProduct().getPid()));
            item.setCount(count);
        }
    }


<form action="Buy.jsp" method="get">
            <input type="hidden" name="action" value="update" />
...
<td>
                        <input type="text" name="<%="p" + ci.getProduct().getPid()%>"
                            value="<%=ci.getCount()%>" size="3" /><!--           -->
</td>

...
<td colspan="7">
                        <a href="Confirm.jsp">  </a>&nbsp;
                        <a href="javascript:document.forms[0].submit()">  </a>
                    </td><!--           -->