nevernam 2010-06-04 16:47
浏览 292
已采纳

【extjs】Ext.data.HttpProxy的问题,关于grid加载acion返回数据(struts2)

如题,初学extjs
[code="java"]
var store =new Ext.data.JsonStore({
autoLoad:true,
proxy:new Ext.data.HttpProxy({url:"http://localhost:8080/rbs/Login_testLogin.action"}),
// data:[{"id":1,"name":"图片","typeValue":"pic"},{"id":2,"name":"视频","typeValue":"avi"}],
fields:["id","name","typeValue"],

})

[/code]

上面的代码中,url里的action返回的string结果就是下面注释行中data的内容

但是当我使用注释行里写死的数据的时候,grid才能加载到数据,而用proxy获取action返回数据的时候,却不行

然后是action的代码
[code="java"]
List lt = service.findListByParam("from Types types");

    JSONArray jsonObject = JSONArray.fromObject(lt);   

    outputStr = jsonObject.toString();

    System.out.println(outputStr);

    PrintWriter out = ServletActionContext.getResponse().getWriter();

    getResponse().setContentType("text/javascript;charset=GBK");

    out.print(outputStr);

    return null; 

[/code]

  • 写回答

3条回答 默认 最新

  • chem_zqm 2010-06-05 11:23
    关注

    你不会是用本地的方式打开的页面吧?那样肯定是不能向后台发起请求的,另外,跨域请求一般也是行不通的

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?