struts2的select标签,大家看我用法对不对,怎么老是抱错
我在Action里定义的
private List<FundsType> fundstype;
private List<ConstruNature> construnature;
private String funds;
private String constru;
都有自己的setter/getter方法
然后再Action的构造函数里,那个FundsType和ConstruNature的构造函数就是让他们的name属性赋值,里面都有一个name属性
public newProjectAction()
{
FundsType[] dt = new FundsType[2];
dt[0] = new FundsType("test");
dt[1] = new FundsType("test2");
ConstruNature[] cn = new ConstruNature[2];
cn[0] = new ConstruNature("test1");
cn[1] = new ConstruNature("test2");
fundstype = Arrays.asList(dt);
construnature = Arrays.asList(cn);
}
接下来是表单的代码
<s:form action="newProject.action" method="post" enctype="application/x-www-form-urlencoded" name="newproject"> <table width="300" border="0"> <tr> <th scope="row"> 资金来源 </th> <td> <s:select list="fundstype" name="funds" listKey="name" listValue="name" emptyOption="true" headerKey="None" headerValue="None" /> </td> </tr> <tr> <th scope="row"> 建设类型 </th> <td> <s:select list="construnature" name="constru" listKey="name" listValue="name" emptyOption="true" headerKey="None" headerValue="None" /> </td> </tr> y