ylfighter
2011-04-29 10:37
浏览 269

Ext 的store通过HttpProxy 和 JsonReader 获取不了数据..

郁闷好几天... store 里还是没有数据... 真的查不出来原因...
兄弟们 指导下啊!!!

[b]1. companyList.js[/b]
[code="js"]var proxy = new Ext.data.HttpProxy({url: 'companyData.jsp'});
//

var reader = new Ext.data.JsonReader(
{
root: 'data'
},[
{name: 'companyId', type: 'int'},
{name: 'companyName'},
{name: 'shortName'},
{name: 'companyType'},
{name: 'parentCompany'},
{name: 'insertDate', type: 'date', dateFormat: 'Y/m/d'}

]
)

var store = new Ext.data.JsonStore(    {
  proxy: proxy,
  reader: reader
});

store.load();   [/code]

[b]2.companyData.jsp[/b]
[code="java"]
<%

Company company1 = new Company(1, "山东", "SD", "SS", "0", new Date());
Company company2 = new Company(2, "河南", "SD", "SS", "0", new Date());
List<Company> list = new ArrayList<Company>(); 
list.add(company1);
list.add(company2);
JSONArray jsonArray = JSONArray.fromObject(list); 
JSONObject json = new JSONObject();
json.put("data", jsonArray);
response.setContentType("application/x-json");
//String cb = request.getParameter("callback");
//response.setContentType("text/javascript");
//out.write(cb + "(");
out.print(json); 
//out.write(");");

%>
[/code]

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • caoruitan 2011-04-29 15:17
    已采纳

    你用firebug监测一下看看是否已经响应到前台,如果有响应结果你可以再试一下把contentType修改为text/plain试一下

    点赞 打赏 评论

相关推荐 更多相似问题