struts多行数据提交解决方案二
来源:互联网 发布:阿里云ubuntu图形界面 编辑:程序博客网 时间:2024/04/28 16:07
ActionForm中的一个ArrayList, 页面上可以用<html:iterator>实现循环显示, 但是怎么样才能在提交时使页面上这些循环显示的数据自动提交呢?
这里主要用到了common-collection包.
FormBean:
代码
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections.Factory;
import org.apache.commons.collections.list.LazyList;
import org.apache.struts.action.ActionForm;
import com.yourcompany.struts.action.UserVo;
public class TestForm extends ActionForm ...{
public TestForm() ...{
Factory factory = new Factory() ...{
public Object create() ...{
return new UserVo();
}
};
this.contents = LazyList.decorate(new ArrayList(), factory);
}
// --------------------------------------------------------- Instance Variables
private List contents;
// --------------------------------------------------------- Methods
public List getContents() ...{
return contents;
}
public void setContents(List contents) ...{
this.contents = contents;
}
}
import java.util.List;
import org.apache.commons.collections.Factory;
import org.apache.commons.collections.list.LazyList;
import org.apache.struts.action.ActionForm;
import com.yourcompany.struts.action.UserVo;
public class TestForm extends ActionForm ...{
public TestForm() ...{
Factory factory = new Factory() ...{
public Object create() ...{
return new UserVo();
}
};
this.contents = LazyList.decorate(new ArrayList(), factory);
}
// --------------------------------------------------------- Instance Variables
private List contents;
// --------------------------------------------------------- Methods
public List getContents() ...{
return contents;
}
public void setContents(List contents) ...{
this.contents = contents;
}
}
如上,ActionForm中的构造函数是必须的.
JSP:
代码
<nested:iterate property="contents" indexId="index">
<nested:text property="year"/>
<nested:text property="month"/><br/>
</nested:iterate>
<nested:text property="year"/>
<nested:text property="month"/><br/>
</nested:iterate>
ok,就这么简单!
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1615225
- struts多行数据提交解决方案二
- struts多行数据提交解决方案二(LazyList)
- struts多行数据提交解决方案
- struts多行数据提交解决方案
- Struts中多行数据的提交
- Struts中多行数据的提交
- 移:使用Struts提交多行数据
- 提交多行数据到Struts的ActionForm的List属性中
- 多行数据提交到Struts的ActionForm的List属性中
- 提交多行数据到Struts的ActionForm的List属性中
- 使用struts提交多行数据到list属性中的常见错误及相关知识
- 多行数据提交到Struts的ActionForm的List属性中
- 多行数据提交到Struts的ActionForm的List属性中
- 多行数据提交到Struts的ActionForm的List属性中
- Struts1 table提交多行数据
- struts2 多行数据同时提交解决方法
- javaweb多行数据提交问题
- PHP,Form提交多行数据处理
- GridView在编辑的时候控制编辑框的列宽。
- dedecms中实现文章正文内容添加广告
- 详细设计和概要设计的思考
- 如何实现为一个网卡绑定多个IP地址
- 什么是动态语言?
- struts多行数据提交解决方案二
- 每个.Net开发人员应该下载的十种必备工具
- 更改网络登陆用户的名称与密码
- Activex和javaScript结合使用
- A tiny C-like library(类C语言的库)
- ASP.NET随机显示数据库记录
- 最近想学编译原理
- java程序员面试必备
- dynamic_cast