2013-07-30 66 views
0

我將以下代碼導入Jsp,根據從數據庫中檢索的參數值動態生成一個表。我想要在每一行旁邊都有一個編輯按鈕,並按提交,我想將表單提交給我的servlet。然而 我不能把內部的和我想幫助..這裏是代碼:表單未提交到JSP表中

<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> 

回答

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> 
+0

喜亞歷克斯, 似乎這一個沒有解決的問題,我仍然有問題,任何替代? –