2011-04-25 42 views
0

我不斷收到以下struts錯誤:奇怪和真氣struts問題!

description服務器遇到內部錯誤(),導致無法完成此請求。

例外

org.apache.jasper.JasperException: tag 'select', field 'list', name 'dept': The requested list key 'deptList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] 

。 。 。

這裏是我的.jsp文件中的代碼:

  <s:select name="dept" list="deptList" listKey="deptId" listValue="deptString" headerKey="0" headerValue="Select a Department" 
     label="Select Department" /> 

這裏是我的操作文件中的代碼(我有調試verifyed它返回正確的值):

  @Override 
      public String execute() throws Exception { 
      org.springframework.web.context.ContextLoaderListener c = new     org.springframework.web.context.ContextLoaderListener(); 
      EmployeeDao dao = (EmployeeDao) ContextLoader.getCurrentWebApplicationContext().getBean("employeeDao");     
      deptList=dao.getDeptsList();      
      //Employee employee=dao.getEmployeeforHRList(getLname(), getFname()); 
      return SUCCESS; 
      } 

這裏是我的數據訪問文件的代碼:

  public List<Department> getDeptsList(){ 
      String query = "from Department";   
      List<Department> departments = getSession().createQuery(query).list(); 
      return departments; 
      } 
+0

我沒有看到執行方法中的任何代碼將獲取的集合設置到表單bean中? – 2011-04-25 04:38:37

+0

這是我的struts.xml文件中與此相關的部分: – Mike 2011-04-25 05:00:00

+0

對不起。 。 。點擊錯誤的按鈕:<! - 此操作將填充人力資源頁面中的部門列表 - > human_res。 JSP <結果名稱= 「無」> human_res.jsp <結果名稱= 「輸入」> human_res.jsp <結果名稱= 「錯誤」> human_res.jsp \t我真的需要一個形式只是一個下拉列表?沒有數據只能從數據庫中輸入。 – Mike 2011-04-25 05:00:58

回答

4

您需要的列表中設置成的formBean

您正在從jsp尋找集合,並且您沒有在FormBean中設置該集合,或者您也可以使用適當的EL將它設置在請求/頁面/會話/應用程序範圍中。

+0

不客氣:) – 2011-04-25 13:46:02