本人第一次用EXT,试了好几次还是不知道怎么将后台传出的LIST在前台获取,高手帮忙看一看这个是我模仿别人写的从后台获取数据的例子,可怎么也没有数据显示出来,我想问问大家我到底是哪里写错了???????????????????????????????????????????? var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'queryuser.action'}),
id:'userList',
reader: new Ext.data.JsonReader({
userCode: 'userCode',
userName: 'userName'
},[{name:'userID',mapping:'userID'},{name:'department',mapping:'department'},{name:'departmentCode',mapping:'departmentCode'}]
)
}); 官方例子上用的是XML数据格式
var store = new Ext.data.Store({
// destroy the store if the grid is destroyed
autoDestroy: true, // load remote data using HTTP
url: 'plants.xml', // specify a XmlReader (coincides with the XML format of the returned data)
reader: new Ext.data.XmlReader({
// records will have a 'plant' tag
record: 'plant',
// use an Array of field definition objects to implicitly create a Record constructor
fields: [
// the 'name' below matches the tag name to read, except 'availDate'
// which is mapped to the tag 'availability'
{name: 'common', type: 'string'},
{name: 'botanical', type: 'string'},
{name: 'light'},
{name: 'price', type: 'float'},
// dates can be automatically converted by specifying dateFormat
{name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
{name: 'indoor', type: 'bool'}
]
}), sortInfo: {field:'common', direction:'ASC'}
});
proxy: new Ext.data.HttpProxy({url: 'queryuser.action'}),
id:'userList',
reader: new Ext.data.JsonReader({
userCode: 'userCode',
userName: 'userName'
},[{name:'userID',mapping:'userID'},{name:'department',mapping:'department'},{name:'departmentCode',mapping:'departmentCode'}]
)
}); 官方例子上用的是XML数据格式
var store = new Ext.data.Store({
// destroy the store if the grid is destroyed
autoDestroy: true, // load remote data using HTTP
url: 'plants.xml', // specify a XmlReader (coincides with the XML format of the returned data)
reader: new Ext.data.XmlReader({
// records will have a 'plant' tag
record: 'plant',
// use an Array of field definition objects to implicitly create a Record constructor
fields: [
// the 'name' below matches the tag name to read, except 'availDate'
// which is mapped to the tag 'availability'
{name: 'common', type: 'string'},
{name: 'botanical', type: 'string'},
{name: 'light'},
{name: 'price', type: 'float'},
// dates can be automatically converted by specifying dateFormat
{name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
{name: 'indoor', type: 'bool'}
]
}), sortInfo: {field:'common', direction:'ASC'}
});
或者你在EXT直接用local类型的store 把JSON写在页面里 先试试页面能不能正常显示 然后改后台
List<JSONObject> jsonlist =new ArrayList<JSONObject>();
for(Object object: userList){
JSONObject json= JSONObject.fromObject(object);
jsonlist.add(json);
}
String json=jsonlist.toString();
response.setCharacterEncoding("UTF-8");
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
StringBuffer sb = new StringBuffer();
sb.append("<script language=\"javaScript\">\r\n");
sb.append("location.href=\"/Shilikaifa2/userd.do?action=queryUser\";");
sb.append("</script>\r\n");
out.print(json);
out.println(sb.toString());
out.flush();
out.close();
这样子又传路径又传JSON化的LIST,好像有问题,但是我又不能说直接return.mapping.forward("123");
请问我该怎么办呢