ExtJS paging using JSP to pass data samples _extjs

Source: Internet
Author: User
Tags stringbuffer
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: "Show from {0} Data to {1} strip data, total {2} data,
store:store3,
pagesize:50
});

var grade = new Ext.grid.GridPanel ({
title: "Data List",
store:store3,
height:300,
Bbar:pagingtoolba R,
columns: [{
header: ' id ',
dataindex: ' id ',
width:300
}, {
header: ' name ',
dat Aindex: "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 < 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 In addition to @page can not have other text

<%@ page language= "java" contenttype= "text/html; Charset=iso-8859-1 "
pageencoding=" iso-8859-1 "%>
${info}"

web.xml***************

<?xml version= "1.0" encoding= "UTF-8"?> <web-app xmlns:xsi=
"Http://www.w3.org/2001/XMLSchema-instance" "
xmlns=" Http://java.sun.com/xml/ns/javaee "xmlns:web=" http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "
xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id= "webapp_id" version= "2.5" >
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>com.aa.TestAction</servlet-class>
</servlet>
<servlet-mapping >
<servlet-name>test</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file >
</welcome-file-list>
</web-app>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.