ScriptTagProxy与jsp后台交互实例
ScriptTagProxy与jsp后台交互实例
---->js
Ext.onReady(function(){var personRecord = new Ext.data.Record.create([{name:"name",type:"string"},{name:"sex",type:"string"}])var pDate = new personRecord({name:"steven",sex:"boy"});var store = new Ext.data.Store({//proxy:new Ext.data.HttpProxy({url:"http://localhost:8080/extTest/data.jsp"}),proxy:new Ext.data.ScriptTagProxy({url:"http://192.188.60.97:8080/extTest/data.jsp"}),reader: new Ext.data.ArrayReader({},personRecord)}) store.load(); var grid = new Ext.grid.GridPanel({ store: store, columns: [ {header: 'name', dataIndex: 'name'}, {header: 'sex', dataInex: 'sex'} ], autoHeight: true, renderTo: 'grid' }); });
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><%boolean flag = false;String cbStr = request.getParameter("callback");if(cbStr != null){flag = true;response.setContentType("text/javascript");out.print(cbStr+"(");}else{response.setContentType("application/x-json");}out.print("[" + "['jim','boy']," + "['tom','boy']," + "['kit','girl']" + "]");if(flag){out.print(");");}System.out.println(cbStr);%>