struts1 actionForm 如何提交集合

jiabiaoli 2014-04-23 03:40:50
<logic:empty name="capitalByAutonomys">
<tr align="center">
<td colspan="4">无 记 录 !</td>
</tr>
</logic:empty>
<logic:notEmpty name="capitalByAutonomys">
<logic:iterate id="autonomy" name="capitalByAutonomys"
indexId="index">
<tr align="center" onMouseover="mouseover(this);">
<td><bean:write name='autonomy'
property='organization.description' /><input type="text"
name="capitalByAutonomys.organization.id"
value='<bean:write name="autonomy" property="organization.id"/>' />
</td>
<td><INPUT type="text" name="capitalByAutonomys.investment"
value='<bean:write name="autonomy" property="investment" />'
class="ädd line30" /></td>
<td></td>
<td></td>
</tr>
</logic:iterate>
</logic:notEmpty>
...全文
148 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
szw80317027 2014-04-23
  • 打赏
  • 举报
回复
你在前台把你的name属性设置成类似于 xxx[0].xxx的格式 到后台去取就行了 假设有一个用户对象(User),有name属性那么就这样写 user[0].name,user[1].name 这样到后台你就可以取到User对象的list了
tony4geek 2014-04-23
  • 打赏
  • 举报
回复
1.在org.apache.struts.action.DynaActionForm类中有这个方法用于获取字符串数组 public String[] getStrings(String name) { return (String[]) this.get(name); } 2.在structs-config.xml中配置按数组传递的变量 <form-beans> <form-bean name="dynaForm" <form-property name="userid" type="java.lang.String[]"/><!-要传递的参数,以字符串数组方式传递-> </form-bean> </form-beans> 3.在action中调用1中的方法获取数值 DynaActionForm uf = (DynaActionForm)form; String[] userid = (String[]) uf.getStrings("userid");

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧