action:
public class StudentAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -4514107777773878982L;
public List <Student> departments;
public List<Student> getDepartments() {
return this.departments;
}
public List<Student> getAllDepartments() {
return null;
}
public void setDepartments(List<Student> departments) {
this.departments = departments;
}
}
struts.xml
<action name="studentAction" class="jp.panitec.action.StudentAction" method="getAllDepartments"/>
applicationContext.xml
<bean id="studentAction"
class="jp.panitec.action.StudentAction">
<property name="studentManager">
<ref local="studentManager"/>
</property>
</bean>
jsp
<td>性別</td>
<td>
<s:select list="#StudentAction.departments" name="gender"
value="gender" listKey="emp_id" listValue="name"></s:select>
</td>
student 表中部分字段:
public class Student implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5005917481973631062L;
private jp.panitec.model.StudentPK comp_id;
private byte[] photo;
private String name;
private String gender;
}
错误信息
2008/05/29 17:43:01 org.apache.catalina.core.StandardWrapperValve invoke
致命的: サーブレット jsp のServlet.service()が例外を投げました
tag 'select', field 'list', name 'gender': The requested list key '#StudentAction.departments' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:231)
如何修改 给个好的建议吧