后台信息:
JSONArray array=new JSONArray();
JSONObject json1=new JSONObject();
json1.put("hc","dwg");
array.add(json1);
JSONObject json2=new JSONObject();
json2.put("pp", "baichi");
array.add(json2);
JSONObject obj=new JSONObject();
obj.put("success", true);
obj.put("root", array);
out.print(obj);
*****************************************************************
后台输出json数据:
{"success":true,"root":[{"hc":"dwg"},{"pp":"baichi"}]}
******************************************************************
js内容:
var updateform=new Ext.FormPanel({
labelAlign: 'right',
frame:true,
labelWidth:85,
autoScroll:true,
width:660,
reader: new Ext.data.JsonReader(
{root:'root'},
[
{name:'hc',mapping:'hc',type:'string'},
{name:'pp',mapping:'pp',type:'string'}
]
),
items: [{
xtype:'fieldset',
title:'信息',
autoHeight:true,
layout:'column',
items:[
{columnWidth:.8,layout: 'form',border:true,
items: [
{xtype:'textfield',fieldLabel: '姓 名',name: 'hc',anchor:'90%' },
{xtype:'textfield',fieldLabel: '密 码',name: 'pp',anchor:'90%'}
]
}
]
}],
buttons: [{
text: '确 定',
handler:function(){
updateform.form.load({
url:'TestServlet',
method:'post'
});
}
},{
text: '取 消',
handler : function(){
win.hide();
}
}]
})
***********************************************************************************
加载显示页面:
********************************************************************
问题:点击“确定”按钮,只能加载JSONArray 第一个添加的数据,也就是
*JSONObject json1=new JSONObject();
json1.put("hc","dwg");
array.add(json1);*
的值,我将json1和json2添加到jsonarray中的顺序换一下,还是只显示第一个添加的值,请各位高手帮帮忙,看看这是什么原因,多谢!