论坛首页 入门技术论坛

struts2 <s:select>标签错误信息

浏览 2457 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-05-29  

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)

如何修改 给个好的建议吧

   发表时间:2008-05-30  
<s:select list="#StudentAction.departments" name="gender"
      value="gender" listKey="emp_id" listValue="name"></s:select>中的#StudentAction.不要,修改为
<s:select list="departments" name="gender"
      value="gender" listKey="emp_id" listValue="name"></s:select>



0 请登录后投票
   发表时间:2008-05-30  
补充一下,value="gender"也不要
<s:select list="departments" name="gender"
listKey="emp_id" listValue="name"></s:select>

emp_id?帖出的代码中怎么没找到
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics