首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2批量增添

2012-10-09 
struts2批量添加publicclass Product {private String nameprivatedouble price...}publicclass Product

struts2批量添加
publicclass Product {
    private String name;
    privatedouble price;
    ...
}

publicclass ProductConfirm extends ActionSupport {
    public List<Product> products;
    ...
   
    @Override
    public String execute() {
        for(Product p : products) {
            System.out.println(p.getName() + " | "+ p.getPrice());
        }
        return SUCCESS;
    }
}
在同上的包中ProductConfirm-conversion.properties,
代码如下:Element_products=tutorial.Product

<s:form action="ProductConfirm" theme="simple">           
<table>
<s:iterator value="new int[3]" status="stat">
<tr>
<td><s:textfield name="%{'products['+#stat.index+'].name'}"/></td>
<td><s:textfield name="%{'products['+#stat.index+'].price'}"/></td> </tr>
</s:iterator>
</table>
</s:form>  1 楼 lykm02 2011-04-15   这个用于显示是可以的。但是批量添加的话,看你的code,应该是每次提交3个。
有没有更好的方案?

热点排行