当前页面: 开发资料首页 → JSP 专题 → struts 把前台的数据直接打包成对象数组的问题
struts 把前台的数据直接打包成对象数组的问题
摘要: struts 把前台的数据直接打包成对象数组的问题
假设有类A
从前台传到后台的数据为多个A的对象的数据。
我希望通过formbean 传递到后台以后能直接打包成类A的数组。
求struts的实现方法、主要是前台和formbean的写法
能不能说详细点啊
多个A对象的数据就是list了
在formbean里定义一个list
以下列子可以参考一下 schedule为formbean定义的list中存放的对象
页面中
<tr id='schedule
<td width="10%" noWrap>开始时间</td>
<td>
</td>
<td width="10%" noWrap>完成时间</td>
<td>
</td>
</tr>
formbean中
加入
public ScheduleTemplateData getSchedule(int index)
{
List scheduleList = projectInfoData.getScheduleList();
while (index >= scheduleList.size())
{
scheduleList.add(new ScheduleTemplateData());
}
return (ScheduleTemplateData) scheduleList.get(index);
}
public void setSchedule(int index, ScheduleTemplateData schedule)
{
List scheduleList = projectInfoData.getScheduleList();
scheduleList.set(index, schedule);
}
后台可直接调用
List sumScheduleList = projectInfoData.getScheduleList();
得到页面schedule对象列表
如果前台不想使用struts taglib,
indexed="true" 怎么表达