表单不会在表中提交到JSP中

时间:2013-07-30 17:29:01

标签: forms jsp form-submit

我将以下代码放入Jsp中,我根据从Data Base检索的参数值动态生成表。我希望每行旁边都有一个编辑按钮,按提交我想向我的servlet提交一个表单。 但我不能把一个内部和我想要一个帮助..这里是代码:

<table border="1">
                <tr>
                    <th>Customer Name</th>
                    <th>Customer Surname</th>
                    <th>Customer Email</th>
                    <th>Customer Adress</th>
                    <th>Customer Contact Details</th>


                </tr>

                <c:forEach items="${ccustomers}" var="customer" >

                    <tr>
                           <form  action="myController" method="POST">
                        <td><input value="${customer.customerName}" name="customerNameEdit"/></td>
                        <td><input value="${customer.customerSurname}" name="searchForCustomerSurName"/></td>
                        <td><input value="${customer.email}" name="customerEmailEdit"/></td>
                        <td><input value="${customer.adress}" name="customerAdressEdit"/></td>
                        <td><input value="${customer.phoneNumber}" name="customerPhoneEdit"/></td>
                        <input type="button" value="edit" onclick="this.form.submit()"/>
                        <input type="hidden" name="<%=WebParamsList.PARAM_PAGENAME%>" value="searchPage"/>
                        <input type="hidden" name="<%=WebParamsList.SEARCHCRITERIA%>" value="customers"/>
                        <input type="hidden" name="customerIdForEdit" value="${customer.customerId}"/>
                        <input type="hidden" name="<%=WebParamsList.RESULTPAGEPARAM%>" value="edit"/>
                      </form>
                </tr>

            </c:forEach>
        </table>

1 个答案:

答案 0 :(得分:0)

将您的按钮和其他隐藏字段放入最后一个表列。它应该是这样的:

<form  action="myController" method="POST">
<tr>
   <td><input value="${customer.customerName}" name="customerNameEdit"/></td>
   <td><input value="${customer.customerSurname}" name="searchForCustomerSurName"/></td>
   <td><input value="${customer.email}" name="customerEmailEdit"/></td>
   <td><input value="${customer.adress}" name="customerAdressEdit"/></td>
   <td><input value="${customer.phoneNumber}" name="customerPhoneEdit"/></td>
   <td>
       <input type="button" value="edit" onclick="this.form.submit()"/>
       <input type="hidden" name="<%=WebParamsList.PARAM_PAGENAME%>" value="searchPage"/>
       <input type="hidden" name="<%=WebParamsList.SEARCHCRITERIA%>" value="customers"/>
       <input type="hidden" name="customerIdForEdit" value="${customer.customerId}"/>
       <input type="hidden" name="<%=WebParamsList.RESULTPAGEPARAM%>" value="edit"/>
   </td>
</tr>
</form>