我張貼了這麼多問題抱歉,我想我需要閱讀更多的...Struts2的:請求列表鍵無法解析錯誤
但首先我想知道你們是否能幫助我解決這個問題,它已經困擾我很長一段時間了,並一直在想,爲什麼它不起作用。
(這有什麼好做的以前的錯誤沒有得到要解決這個問題,和一個新的出來:X)
我有,我想填充到另一個列表,但在這樣做的過程中,我得到了錯誤的標題爲:The requested list key could not be resolved as a collection/array/map/enumeration/iterator type.
我環顧四周,並試圖代碼,但它仍然沒有真正似乎工作。這裏是我的代碼:
JSP(和jQuery):
<s:select id="feb" name="feb" headerKey="-1" list="febList"
listKey="key" listValue="description" theme="simple" cssClass="formfields" />
$('select#feb').change(function() {
$.ajax({
url: "AnnotateSearchList?feb="+$(this).val()+"&dept="+$("#dept").val(),
dataType :'json',
type:'GET',
contentType: 'application/json',
success : function(data) {
alert('test');
},
error: function(){
alert('Error');
}
})
});
的方法: 公共字符串doGetSelectedList() {
this.output = new StringBufferInputStream("");
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
Calendar startCalendar = Calendar.getInstance();
startCalendar.add(Calendar.DAY_OF_YEAR, -3);
Calendar endCalendar = Calendar.getInstance();
if (this.startDate == null || this.startDate.equals("")) {
this.startDate = sdf.format(startCalendar.getTime()).toString();
}
if (this.endDate == null || this.endDate.equals("")) {
this.endDate = sdf.format(endCalendar.getTime()).toString();
}
System.out.println("Feb "+this.feb);
System.out.println("Dept "+this.dept);
this.optionList =xxx.getList(this.feb, this.dept, this.startDate, this.endDate);
ArrayList<SelectItemsData> optList = new ArrayList<SelectItemsData>();
for(String list : optionList){
optList.add(new SelectItemsData(list, list));
}
System.out.println("Size of list: "+this.optionList.size());
System.out.println(optList.size());
String json = new Gson().toJson(optList);
logger.sendMessage(getClass().getSimpleName(), LogHandler.INFO, json);
//System.out.println(json);
try {
response.setContentType("Application/json");
response.getWriter().write(json);
this.output = new StringBufferInputStream(json);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return SUCCESS;
}
//數據爲SelectItemsData持有人: SelectItemsData(字符串鍵,字符串描述);
支柱/ XML:
<action name="AnnotateSearchList" class="mycompanyName.ajax.actions.ParetoChartCore" method="doGetSelectedList">
<result type="stream">
<param name="contentType">application/json</param>
<param name="inputName">output</param>
</result>
<result name="success">/ParetoChart.jsp</result>
</action>
我要去上錯了地方?我的結果實際上是返回到同一頁面,所以我認爲這可能是錯誤的可能原因。 謝謝。
你如何設置'febList'並辦理[選擇標記(http://struts.apache.org/2.3.1/docs/select.html)文檔,看看'listKey'和'listValue'作品爲您的錯誤,說其無法找到鑰匙 – 2012-03-28 10:34:57
嗯,列表正從execute()方法獲取。 – 2012-03-28 11:01:05
顯示的代碼執行方法 – 2012-03-28 11:35:04