struts2 批量添加

1.在Action中定義,List<Product>屬性(Product爲pojo)

2.jsp頁面中:

 <s:iterator value="new int[3]" status="stat">

                <tr>

                    <td><s:textfield name="%{'productList['+#stat.index+'].name'}"/></td>

                    <td><s:textfield name="%{'productList['+#stat.index+'].price'}"/></td>

                    <td><s:textfield name="%{'productList['+#stat.index+'].dateOfProduction'}"/></td>

                </tr>

            </s:iterator>

其中productList爲Action的List屬性名,name,price,dateOfProduction爲Product的屬性

3.定義屬性文件(與Action同一目錄),Action名稱-converstion.properties,格式爲:Element_屬性名=Product

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章