public class TestForm extends ActionForm {
private String address;
private String method;
private TestSubForm[] subTest;
..........................
}
public class TestSubForm extends ActionForm {
private String id;
private String name ;
private String value;
........................
}
有两个存在这种嵌套关系的数组,TestSubForm[] 数组大小不确定。
jsp页面如下:
<input name="address" type="text" value="">
<input name="name" type="text" value="">
<input name="value" type="text" value="">
<input name="name" type="text" value="">
<input name="value" type="text" value="">
<input name="name" type="text" value="">
<input name="value" type="text" value="">
在action中怎么才能直接TestForm 对象,并且可以遍历TestSubForm数组
问题补充:
假如按 zhai puhong的方法把
private TestSubForm[] subTest;
改为
private list subTest;
那么在action处理类中
public class ValuationAction extends DispatchAction {
public ActionForward list(......){
TestForm testForm = new TestForm();
testForm = (TestForm)form;
if(testForm!=null){
List subFormList = testForm.getSubTest();
}
return mapping.findForward("list");
}
}
好像subFormList是空的 并不是我希望的TestSubForm集合