2013-03-13 83 views
0

我有下面的代碼來顯示一個列表給用戶選擇一個選項,它正確地顯示了列表選項,但是當一個選項被選中並且表單被提交時,它會出現以下錯誤。如何提交下拉列表的選定選項?

錯誤

Caused by: tag 'select', field 'list', name 'developerID': The requested list key 
'listOfdevelopers' could not be resolved as a collection/array/map/enumeration/iterator type. 
Example: people or people.{name} - [unknown location] 

JSP

<s:form ...> 
    <s:select name="developerID" 
         label="developerID" 
         list="listOfdevelopers" 
         value="%{development.developerID}" 
         /> 
</s:form> 

我的代碼

.... 
private Map listOfdevelopers; 
private Development development = new Development(); 

public Map getListOfdevelopers() { 
    return listOfdevelopers; 
} 

public void setListOfdevelopers(Map listOfdevelopers) { 
    this.listOfdevelopers = listOfdevelopers; 
} 

public Development getDevelopment() { 
    return development; 
} 

public void setDevelopment(Development development) { 
    this.development = development; 
} 

@Override 
public Development getModel() { 
    return this.development; 
} 
...  
+0

你是不是在提交填充地圖。 – 2013-03-13 11:03:06

+1

有沒有代碼在哪裏填充集合? – 2013-03-13 18:01:01

+0

@Daniel Morgan可以顯示struts.xml – PSR 2013-03-14 07:00:39

回答

0
<s:select list="listOfdevelopers" 
         id="developerID" 
         name="developerID" 
          label="developerID" 
          headerKey="" 
           headerValue="Please choose one." 
          value="%{development.developerID}" 
         /> 

例如

<s:select list="genderList" 
      id="gender" 
      name="gender" 
      cssClass="listmenu validate-selection" 
      listKey="name" 
      listValue="details" 
      headerKey="" 
      value="userInfo.userPersonalInfo.gender" 
      headerValue="Please choose one." 
      ></s:select> 
+0

我試過了,但遇到了同樣的錯誤。 – 2013-03-13 23:20:48

-1

其實問題是你S:選擇,這裏值標籤引起的問題。

試試這個

<s:select list="listOfdevelopers" 
       name="developerID" 
       headerKey="-1" 
       headerValue="Select Any Developer" 
       listKey="developerID"    // your collection_element 
       listValue="developer_name"   // your collection_element 
    /> 
+1

如何回答OP問題? – 2013-03-13 11:02:37

+0

我沒有得到你,你會詳細說明你在說什麼 – 2013-03-13 11:08:24

+1

這不是問題的答案。錯誤是因爲「listOfdevelopers」而不是因爲價值。 – 2013-03-13 11:11:00

相關問題