jsp页面

js代码:

  1. $(function() {
  2. $('#ff').hide();
  3. $('#tt').datagrid({
  4. title : '信息显示',
  5. iconCls : 'icon-save',
  6. width : 'auto',
  7. height : 'auto',
  8. pageSize:10,
  9. pageList : [ 5, 10, 15 ],
  10. nowrap : true,
  11. striped : true,
  12. collapsible : true,
  13. url : 'pecc/peccList.action',
  14. loadMsg : '数据装载中......',
  15. onLoadError : function() {
  16. alert('数据加载失败!');
  17. },
  18. sortName : 'code',
  19. sortOrder : 'desc',
  20. remoteSort : false,
  21. frozenColumns : [ [ {
  22. field : 'ck',
  23. checkbox : true
  24. } ] ],
  25. columns : [ [ {
  26. title : '车牌号',
  27. field : 'carNumber',
  28. width : '100',
  29. rowspan : 2,
  30. align : 'center'
  31. }, {
  32. title : '车主',
  33. field : 'carPer',
  34. width : '100',
  35. rowspan : 2,
  36. align : 'center'
  37. }, {
  38. title : '违章时间',
  39. field : 'pTime',
  40. width : '80',
  41. rowspan : 2,
  42. align : 'center'
  43. }, {
  44. title : '违章地点',
  45. field : 'pPlace',
  46. width : '220',
  47. rowspan : 2,
  48. align : 'center'
  49. }, {
  50. title : '违章原因',
  51. field : 'pCase',
  52. width : '220',
  53. rowspan : 2,
  54. align : 'center'
  55. }, {
  56. title : '来源',
  57. field : 'pOrg',
  58. width : '120',
  59. rowspan : 2,
  60. align : 'center'
  61. }, {
  62. title : '交警大队',
  63. field : 'pPer',
  64. width : '300',
  65. rowspan : 2,
  66. align : 'center'
  67. } ] ],
  68. pagination : true,
  69. rownumbers : true,
  70. toolbar : [ {
  71. text : '全部',
  72. iconCls : 'icon-ok',
  73. handler : function() {
  74. $('#tt').datagrid({
  75. url : 'pecc/peccList.action'
  76. });
  77. }
  78. }, '-', {
  79. text : '添加',
  80. iconCls : 'icon-add',
  81. handler : function() {
  82. openAdd();
  83. $('#ff').show();
  84. $('#ff').form('clear');
  85. $('#ff').appendTo('#aa');
  86. }
  87. }, '-', {
  88. text : '修改',
  89. iconCls : 'icon-edit',
  90. handler : getSelect
  91. }, '-', {
  92. text : '删除',
  93. iconCls : 'icon-remove',
  94. handler : del
  95. }, '-', {
  96. text : '查询',
  97. iconCls : 'icon-search',
  98. handler : function() {
  99. $('#query').window('open');
  100. }
  101. } ]
  102. });
  103. displayMsg();
  104. });
  105. function displayMsg() {
  106. $('#tt').datagrid('getPager').pagination({
  107. displayMsg : '当前显示从{from}到{to}共{total}记录'
  108. });
  109. }

Action 代码:

  1. @Controller
  2. @ParentPackage("mydefault")
  3. @Namespace("")
  4. public class Pecc extends ActionSupport {
  5. private static final long serialVersionUID = 1L;
  6. @Resource
  7. PerinfoService perinfoService;
  8. @Resource
  9. PeccancyService peccancyService;
  10. @Action("/pecc")
  11. public String peccList() {
  12. try {
  13. HttpServletRequest re = ServletActionContext.getRequest();
  14. HttpServletResponse response = ServletActionContext.getResponse();
  15. response.setCharacterEncoding("UTF-8");
  16. PrintWriter out = response.getWriter();
  17. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
  18. JSONArray jsonArray = new JSONArray();
  19. JSONObject jsonobj = new JSONObject();
  20. Map map = new HashMap();
  21. long all = perinfoService.getCount(map);
  22. String page = re.getParameter("page");
  23. String rows = re.getParameter("rows");
  24. // 当前页
  25. int intPage = Integer.parseInt((page == null || page == "0") ? "1" : page);
  26. // 每页显示条数
  27. int number = Integer.parseInt((rows == null || rows == "0") ? "10" : rows);
  28. // 每页的开始记录 第一页为1 第二页为number +1
  29. int start = (intPage - 1) * number;
  30. map.put("page", start);
  31. map.put("pageCount", number);
  32. List list = peccancyService.getList(map);
  33. for (Peccancy con : list) {
  34. jsonobj.put("id", con.getId());
  35. jsonobj.put("carNumber", con.getCarNumber());
  36. jsonobj.put("carPer", con.getCarPer());
  37. jsonobj.put("pTime", sdf.format(con.getPTime()));
  38. jsonobj.put("pPlace", con.getPPlace());
  39. jsonobj.put("pCase", con.getPCase());
  40. jsonobj.put("pOrg", con.getPOrg());
  41. jsonobj.put("pPer", con.getPPer());
  42. jsonArray.add(jsonobj);
  43. }
  44. Map json = new HashMap();
  45. json.put("total", all);// total键 存放总记录数,必须的
  46. json.put("rows", jsonArray);// rows键 存放每页记录 list
  47. jsonobj = JSONObject.fromObject(json);// 格式化result一定要是JSONObject
  48. out.print(jsonobj);
  49. out.flush();
  50. out.close();
  51. } catch (IOException e) {
  52. System.out.println(e);
  53. }
  54. return null;
  55. }

Struts.xml 配置:

  1. <</span>package name="mydefault" extends="struts-default">
  2. <</span>global-results>
  3. <</span>result name="exception">/index.jsp</</span>result>
  4. </</span>global-results>
  5. <</span>global-exception-mappings>
  6. <</span>exception-mapping exception="java.lang.Exception"
  7. result="exception" />
  8. </</span>global-exception-mappings>
  9. </</span>package>



版权声明:本文为博主原创文章,未经博主允许不得转载。

Struts2&nbsp;+&nbsp;easyui的DataGrid&nbsp;分页的更多相关文章

  1. SSh结合Easyui实现Datagrid的分页显示

    近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...

  2. schemaeasyui实例:SSh结合Easyui实现Datagrid的分页显示

    查了好多资料,发现还是不全,干脆自己整理吧,最少保证在我的做法正确的,以免误导读者,也是给自己做个记载吧! 克日学习Easyui,发现非常好用,界面很雅观.将学习的心得在此写下,这篇博客写SSh结合E ...

  3. 实例:SSh结合Easyui实现Datagrid的分页显示

    近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...

  4. EasyUI表格DataGrid前端分页和后端分页的总结

    Demo简介 Demo使用Java.Servlet为后台代码(数据库已添加数据),前端使用EasyUI框架,后台直接返回JSON数据给页面 1.配置Web.xml文件 <?xml version ...

  5. Easyui的datagrid结合hibernate实现数据分页

    最近在学习easyui的使用,在学到datagrid的时候遇到了一些问题,终于抽点时间整理了一下,分享出来,请各位前辈高手多多指教! 1.先来看看效果,二话不说,上图直观! 2.easyui的data ...

  6. EasyUI的datagrid分页

    EasyUI的datagrid分页 前台代码: <script type="text/javascript"> $(function () { //查询 search( ...

  7. easyui的datagrid分页写法小结

    easyui的datagrid分页死活不起作用...沙雕了...不说了上代码 //关闭tab1打开tab2 查询Detail function refundDetail(){ $('#tt').tab ...

  8. 关于Jquery EasyUI中的DataGrid服务器端分页随记

    一.关于DataGrid的分页和排序参数 对于分页参数不需要用户指定,程序在AJAX请求的时候会带上分页和排序需要的参数 每页显示条数:rows 当前页:page 排序字段:sort  [multiS ...

  9. Easyui datagrid 修改分页组件的分页提示信息为中文

    datagrid 修改分页组件的分页提示信息为中文 by:授客 QQ:1033553122 测试环境 jquery-easyui-1.5.3 问题描述 默认分页组件为英文展示,如下,希望改成中文展示 ...

随机推荐

  1. poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 3523   Accepted: 1740 ...

  2. 五个知识体系之-SQL语句大全

    一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备 ...

  3. 【BZOJ4861】[Beijing2017]魔法咒语 矩阵乘法+AC自动机+DP

    [BZOJ4861][Beijing2017]魔法咒语 题意:别看BZ的题面了,去看LOJ的题面吧~ 题解:显然,数据范围明显的分成了两部分:一个是L很小,每个基本词汇长度未知:一个是L很大,每个基本 ...

  4. HIbernate 级联删除

    在一对多的情形下如 Cinema - > Screen; 1.正常在不设置级联(casCade)的情况下 删除一的一方(Cinema)会报外键关联异常 (Screen 中包含Cinema的外键) ...

  5. 九度OJ 1175:打牌 (模式匹配)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:8156 解决:1560 题目描述: 牌只有1到9,手里拿着已经排好序的牌a,对方出牌b,用程序判断手中牌是否能够压过对方出牌.  规则:出牌 ...

  6. 504 Gateway Timeout Error 502 Bad Gateway

    总结 1. 502没有收到相应,或者收到了但不及时? cannot get a response in time 540收到了无效的响应 received an invalid response fr ...

  7. vscode设置默认shell 快速到行

    vscode设置默认shell - CSDN博客 https://blog.csdn.net/butterfly5211314/article/details/78944805 在文件 -> 首 ...

  8. 我的Android进阶之旅------>Android实现音乐示波器、均衡器、重低音和音场功能

    本实例来自于<疯狂Android讲义>,要实现具体的功能,需要了解以下API: MediaPlayer  媒体播放器 Visualizer 频谱 Equalizer 均衡器 BassBoo ...

  9. mac svn 使用

    上传文件 $ svn import file.xls svn://ip/sursen/05I\&V周报 -m "te"   备注: -m "冒号里面一定填写文件 ...

  10. swift和oc的混编

    一.Swift工程中加入oc代码 1.在将oc代码加入到Swift工程的时候Xcode会自动创建一个桥接文件“yourProgectName-Bridging-Header.h”,如果没有创建或者删除 ...