Ext Json无法在页面上显示数据啊??? - Web 开发 / Ajax
代码
JS部分=================
Ext.onReady(function(){
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: window.location.href + "/list!list.action"}),
reader: new Ext.data.JsonReader({root:"results",id:"userId"},[{name:'userId'},{name:'userPass'},
{name:'userName'},{name:'userEmail'},{name:'userTel'}])
});
store.load();
var cm = new Ext.grid.ColumnModel(
[{id:"userId",header:"编号",dataIndex:"userId",sortable:true}
,{header:"用户名",dataIndex:"userName",sortable:true}
,{header:"用户密码",dataIndex:"userPass",sortable:true}
,{header:"用户Email",dataIndex:"userEmail",sortable:true}
,{header:"用户号码",dataIndex:"userTel",sortable:true}]);
var grid = new Ext.grid.GridPanel({
// renderTo:"test1",
width:500,
height:300,
title:"联系人列表",
store:store,
cm:cm,
//height:500,
autoExpandColumn:"userId"
});
grid.render("user");
grid.getSelectionModel().selectFirstRow();
});
html部分
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../script/ext-base.js"></script>
<script type="text/javascript" src="../script/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="../css/ext-all.css" />
<script type="text/javascript" src="../script/examples.js"></script>
<link rel="stylesheet" type="text/css" href="../css/examples.css" />
<script type="text/javascript" src="../script/test/list.js"></script>
</head>
<h2 style="color: red;font: bold;">读取后台数据测试</h2>
<br>
<div id="user"></div>
</html>
Action 部分========================
public String list() throws Exception
{
List<TconfUser> results = listDao.getList();
total = results.size();
System.out.println("===========共有"+results.size()+"条记录");
/*JSONObject jsonData = toJSONObject(total, results);
JsonMVCUtil.jsonResponse(jsonData, request, response);*/
JSONArray array = JSONArray.fromObject(results);
response.getWriter().write(this.jsonString);
return SUCCESS;
}
麻烦大家帮我看看是什么原因啊
我是这样输入的:http://localhost:8082/extjs/test/list.html
------解决方案--------------------
JScript code
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: window.location.href + "/list!list.action"}),
reader: new Ext.data.JsonReader({root:"results",id:"userId"},[{name:'userId'},{name:'userPass'},
{name:'userName'},{name:'userEmail'},{name:'userTel'}])
});
//上面的代码,大概是这个样子的
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: "/list!list.action"}),//这里可