2012-03-28 67 views
1

我张贴了这么多问题抱歉,我想我需要阅读更多的...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> 

我要去上错了地方?我的结果实际上是返回到同一页面,所以我认为这可能是错误的可能原因。 谢谢。

+0

你如何设置'febList'并办理[选择标记(http://struts.apache.org/2.3.1/docs/select.html)文档,看看'listKey'和'listValue'作品为您的错误,说其无法找到钥匙 – 2012-03-28 10:34:57

+0

嗯,列表正从execute()方法获取。 – 2012-03-28 11:01:05

+0

显示的代码执行方法 – 2012-03-28 11:35:04

回答

0

我在struts.xml中改变了“成功”到“成功”和它的工作。

+0

这是因为您之前有两个名为“成功”的结果。然而,这是非常令人困惑的,我强烈建议你不要这样做。 – 2012-03-29 21:36:34