extjs 分页,使用jsp传递数据
2014-05-25 10:32
239 查看
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 : "没有数据",
displayInfo : true,
displayMsg : "显示从{0}条数据到{1}条数据,共{2}条数据",
store : store3,
pageSize : 50
});
var grade = new Ext.grid.GridPanel({
title : "数据列表",
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************注意:jsp除了 @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"?>
<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>
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 : "没有数据",
displayInfo : true,
displayMsg : "显示从{0}条数据到{1}条数据,共{2}条数据",
store : store3,
pageSize : 50
});
var grade = new Ext.grid.GridPanel({
title : "数据列表",
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************注意:jsp除了 @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"?>
<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>
相关文章推荐
- extjs 分页使用jsp传递数据示例
- extjs 分页使用jsp传递数据示例
- Extjs分页使用java实现数据库数据查询
- JSP中获取ExtJS.Ajax前台传递的JSON数据实现过程
- JSP中获取ExtJS.Ajax前台传递的JSON数据实现过程
- JAVA与JSP使用JSON传递数据
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- 使用值栈向JSP中传递数据
- oracle分页(从jsp--->dao层,中间用json格式传递数据),数组的分页
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- ExtJs+MonoRail 使用XML传递数据
- vuejs2.0实现分页组件使用$emit进行事件监听数据传递的方法
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- 使用ExtJs 来显示数据,并实现数据的分页功能
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- 使用FileUpload工具实现文件上传与使用ThreadLocal容器传递数据实现分页查询下载
- JSP_strut2架构下前台接收后台传递到前台之数据并处理以使用的一种方法
- JSP中获取ExtJS.Ajax前台传递的JSON数据
- ExtJS中grid按照使用Expand插件、分组显示、中文拼音首字母排序、改变行背景、列背景、静态数据分页综合案例