Javascript 从JSON到Servlet数据
我开始学习使用ExtJS的UI的JSON,但现在我遇到了一个问题,即如何将数据从servlet传递到JSP combobox 我的servlet的输出已经正常了。(我希望如此。:)这是我的servlet代码Javascript 从JSON到Servlet数据,javascript,json,jsp,servlets,extjs4,Javascript,Json,Jsp,Servlets,Extjs4,我开始学习使用ExtJS的UI的JSON,但现在我遇到了一个问题,即如何将数据从servlet传递到JSP combobox 我的servlet的输出已经正常了。(我希望如此。:)这是我的servlet代码 JSONArray jsonarray = new JSONArray(); ResultSetMetaData rsmd = rs.getMetaData(); int y = 1; while(rs.next())
JSONArray jsonarray = new JSONArray();
ResultSetMetaData rsmd = rs.getMetaData();
int y = 1;
while(rs.next()){
int numColumns = rsmd.getColumnCount();
JSONObject obj = new JSONObject();
for (int i=1; i<numColumns+1; i++) {
String column_name = rsmd.getColumnName(1);
String column_value = rs.getString(i);
obj.put(column_value, y);
}
jsonarray.put(obj);
y++;
}
及
希望我做得对。:)请提供帮助。Ext.data.SimpleStore定义应定义“字段””属性 例如
xtype: 'combo',
name: 'genre',
fieldLabel: 'Genre',
mode: 'local',
store: genres2,
width: 120,
forceSelection: true,
typeAhead: true,
triggerAction: 'all',
emptyText:'Select materials...',
selectOnFocus:true,
displayField: 'column_value'
var genres2 = new Ext.data.SimpleStore({
root: 'rows',
totalProperty: 'totalCount',
method: 'POST',
proxy: new Ext.data.HttpProxy({
url : '/ExtJS_Sample/ConnectionServlet'
}),
autoLoad: true
});
genres2.load();
Ext.data.SimpleStore({
root: 'rows',
fields: [ {name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'}],
totalProperty: 'totalCount',
method: 'POST',
proxy: new Ext.data.HttpProxy({
url : '/ExtJS_Sample/ConnectionServlet'
}),
autoLoad: true
});