在struts2操作上提交的空白字段

时间:2014-03-19 05:16:59

标签: java jsp struts2

  1. arraylist变量名称是itmLst in action。
  2. 项目PurchaseDate,EntryDate,ItemCost和ItemDepreciation字段将显示并从用户接受并提交给操作。
  3. <s:iterator value = "itmLst" status="row_id" var="itmLst" id="itmLst" >
        <s:if test="#row_id.index % 2 == 0">
            <tr class="yellow-bg"> 
        </s:if> 
        <s:else> 
            <tr class="gray-bg">
        </s:else>
        <td  class="label-left">
             <s:property value="itemNo" />
             <s:text name=":" />
             <s:property value="itemName" />
        </td>
        <td class="label-left"> 
           <s:textfield name = "itmLst.purDmys" 
                       value = "%{itmLst[#row_id.index].purDmys}"      
                          id = "purDmys%{#row_id.count}"
                    cssClass = "TCMask[##/##/####,dd/mm/yyyy] textfield-date-month"
                   maxLength = "10" />
        </td>
        <s:if test='itmLst.entCod == "T" || itmLst.entCod == "t"'>
            <td class="label-left"> 
               <s:textfield name = "itmLst.entDmys" 
                           value = "%{itmLst[#row_id.index].entDmys}"  
                              id = "entDmys%{#row_id.count}" 
                        cssClass = "TCMask[##/##/####,dd/mm/yyyy] textfield-date-month" 
                       maxLength = "10" />
         </td>
         </s:if>   
         <s:else>  
             <td class="label-left"> 
                <s:text name="N/A" />
             </td>               
        </s:else>
        <td  class="label-left"> <s:property value="itemStatus" /> </td>
        <td class="label-left"> 
               <s:textfield name = "itmLst.itemCost" 
                              id = "itemCost%{#row_id.count}" 
                           value = "%{itmLst[#row_id.index].itemCost}" 
                        cssClass = "textfield-amount" 
                       maxLength = "10" />
        </td>
        <td class="label-left"> 
             <s:textfield name = "itmLst.itemDepr" 
                            id = "itemDepr%{#row_id.count}" 
                         value = "%{itmLst[#row_id.index].itemDepr}" 
                      cssClass = "textfield-amount" 
                     maxLength = "10" />
         </td>
        <td  class="label-left"> <s:property value="depDmys" /> </td>
        <td  class="label-left"> <s:property value="sgDepAmt" /> </td>
        <td  class="label-left"> 
             <s:select name = "itmLst.actionSel" 
                       list = "#{ 'K':getText('Keep As It Is'),'M':getText('Update Modified Values') ,'D':getText('Delete Item') }" 
                      theme = "simple" />
        </td>
    </tr>
        <s:if test="#row_id.index % 10 == 0">
            <tr align="center" >
                <td colspan="9">
                    <s:submit key = "update" 
                         cssClass = "ovalbutton" 
                           method = "postItems" />
    
                    <s:submit key = "cancel" 
                         cssClass = "ovalbutton" 
                               id = "cancelBtn" 
                           method = "cancel"/>
                </td>
            </tr>
        </s:if>
    </s:iterator>
    

1 个答案:

答案 0 :(得分:1)

当从JSP提交到动作类时,除非您在JSP上命名了itmList[0].itemNoitmList[0].purDmys等元素,否则列表将始终为空白。 您可以在迭代列表时分配这些名称。