最近写了一个Ext中的程序,是使用ComboBox远程加载数据的
写好以后在IE下可以正常运行,但是在FF中却无法显示,郁闷的很,下面把代码贴出来,高手帮忙看看<script type="text/javascript">
Ext.onReady(function(){
var store=new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'http://localhost:8080/demo/person'}),
reader:new Ext.data.JsonReader(
{
totalProperty:'totalProperty',
root:'list'
},[
{name:'id'},
{name:'name'}
])
}); var combo=new Ext.form.ComboBox({
store:store,
displayField:"name",
valueField:"id",
mode:"remote",
emptyText:'选择人物...',
triggerAction:'all',
fieldLabel:'人物信息',
minListWidth:200,
pageSize:5
}); var form=new Ext.form.FormPanel({
title:'数字输入框',
width:300,
height:100,
frame:true,
items:[combo],
renderTo:document.body
});
});
</script>
写好以后在IE下可以正常运行,但是在FF中却无法显示,郁闷的很,下面把代码贴出来,高手帮忙看看<script type="text/javascript">
Ext.onReady(function(){
var store=new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'http://localhost:8080/demo/person'}),
reader:new Ext.data.JsonReader(
{
totalProperty:'totalProperty',
root:'list'
},[
{name:'id'},
{name:'name'}
])
}); var combo=new Ext.form.ComboBox({
store:store,
displayField:"name",
valueField:"id",
mode:"remote",
emptyText:'选择人物...',
triggerAction:'all',
fieldLabel:'人物信息',
minListWidth:200,
pageSize:5
}); var form=new Ext.form.FormPanel({
title:'数字输入框',
width:300,
height:100,
frame:true,
items:[combo],
renderTo:document.body
});
});
</script>
Ext.onReady(function(){
var store=new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'http://localhost:8080/demo/person'}),
reader:new Ext.data.JsonReader(
{
totalProperty:'totalProperty',
root:'list'
},[
{name:'id'},
{name:'name'}
])
}); var combo=new Ext.form.ComboBox({
store:store,
displayField:"name",
valueField:"id",
mode:"remote",
emptyText:'选择人物...',
triggerAction:'all',
fieldLabel:'人物信息',
minListWidth:200,
pageSize:5
}); var form=new Ext.form.FormPanel({
title:'数字输入框',
width:300,
height:100,
frame:true,
items:[combo],
renderTo:document.body
});
});
</script>
//数据对象
public class JSONObject {
private int totalProperty;
private List list; public JSONObject() {
super();
// TODO Auto-generated constructor stub
} public int getTotalProperty() {
return totalProperty;
} public void setTotalProperty(int totalProperty) {
this.totalProperty = totalProperty;
} public List getList() {
return list;
} public void setList(List list) {
this.list = list;
}}
//控制器代码
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=GBK");
request.setCharacterEncoding("GBK");
PersonDao personDao = new PersonDao();
int start = 0, limit = 5;
if (request.getParameter("start") != null) {
start = Integer.parseInt(request.getParameter("start"));
}
if (request.getParameter("limit") != null) {
limit = Integer.parseInt(request.getParameter("limit"));
}
JSONObject jsonObject=new JSONObject();
int totalRecord=personDao.getTotalRecord();
List list = personDao.findPerson(start, limit);
jsonObject.setTotalProperty(totalRecord);
jsonObject.setList(list);
Gson gson = new Gson();
String persons = gson.toJson(jsonObject);
PrintWriter out = response.getWriter();
out.println(persons);
out.close();
}