我有以下正确显示选项的下拉列表,但是当我选择一个项目并提交表单时,它会遇到以下错误:
'select', field 'list', name 'name': The requested list key 'listnames' could not be
resolved as a collection/array/map/enumeration/iterator type. Example: people or
people.{name} - [unknown location]
我的 JSP 表单
<s:form method="POST" action="addNames">
<s:select name="name"
label="Names"
list="listnames"
/>
</s:form>
我的行动
@Action
public class Myaction implements ModelDriven{
private MyClass myclass = new MyClass();
private List listnames = new ArrayList();
@Override
public MyClass getModel() {
return this.myclass;
}
public List getListnames() {
return listnames;
}
public void setListnames(List listnames) {
this.listnames = listnames;
}
public MyClass getMyClass() {
return myclass;
}
public void setMyClass(MyClass myclass) {
this.myClass = myclass;
}
}
我的课
public class MyClass {
private String name;
..... getter and setters go here ....
}
支柱
<package name="MyUsers" extends="default" namespace="/MyUsers">
<action name="*" method="{1}" class="com.myproject.controller.Myaction">
<result name="uAdd" type="tiles" >uAdd</result>
<result name="uView" type="tiles" >uView</result>
</action>
</package>