Extjs implements paging and transmits data using jsp. The specific implementation process is as follows.
Ext. onReady (function () {store3 = new Ext. data. jsonStore ({autoDestroy: true, totalProperty: 'totle', url: 'service. do ', storeId: 'mystore', root: 'data', fields: ['id', "name", "pw"]}); var pagingToolbar = new Ext. pagingToolbar ({emptyMsg: "No data", displayInfo: true, displayMsg: "displays {2} pieces of data from {0} to {1} pieces of data ", store: store3, pageSize: 50}); var grade = new Ext. grid. gridPanel ({title: "data list", store: store3, height: 300, bbar: pagingToolbar, columns: [{header: "id", dataIndex: "id", width: 300 },{ header: "name", dataIndex: "name", width: 300 },{ header: "pw", dataIndex: "pw"}], region: 'center'}); var panel = new Ext. viewport ({layout: 'border', items: [grade]}) ;});
Action ********************
protected void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {List list = new ArrayList();for (int i = 0; i < 50; i++) {Person p = new Person();p.setId("id" + i);p.setName("name" + i);p.setPw("pw" + i);list.add(p);}StringBuffer info = new StringBuffer();info.append("{totle:2000,data:");info.append(JSONArray.fromObject(list));info.append("}");System.out.println(info.toString());System.out.println("*****doPos");request.setAttribute("info", info.toString());request.getRequestDispatcher("/info.jsp").forward(request, response);}
Info. jsp ************* Note: jsp cannot contain any text except @ page.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>${info}
Web. xml ***************
<?xml version="1.0" encoding="UTF-8"?>
test
com.aa.TestAction
test
*.do
index.jsp