1
我開始學習JSON我的ExtJS的供電UI,但現在我有關於如何從我的servlet到JSP組合框傳遞數據的問題..從JSON到Servlet的數據
我的servlet的輸出已經確定。 (我希望如此。:))這是我的servlet代碼..
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++;
}
然後我在ExtJS中的組合框是;
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();
希望我這樣做是正確的。 :) 請幫忙。