bootstrop分页ssm

一时失言乱红尘 2022-06-13 10:21 347阅读 0赞
  1. //查询列表
  2. function findForAjax(currentPage,userId)
  3. {
  4. $.ajax({
  5. url : "/bills/bill/findForAjax",
  6. data : {"currentPage": currentPage,"userId" : userId},
  7. type : "post",
  8. dataType : "json",
  9. async:false, // 如果为异步加载无法给分页标签绑定事件(执行js的时候ajax数据还未加载完成),如果用异步加载需要使用live动态绑定
  10. success : function (data)
  11. {
  12. dealData(data);
  13. dealTable(data);
  14. dealPage(data);
  15. },
  16. error : function(XMLHttpRequest, textStatus, errorThrown)
  17. {
  18. alert(textStatus);
  19. stateCode(XMLHttpRequest);
  20. }
  21. });
  22. }
  23. ${totalCount} ${pageNo} ${pageNo}
  24. //查询列表
  25. function findForAjax(currentPage,userId)
  26. {
  27. $.ajax({
  28. url : "/bills/bill/findForAjax",
  29. data : {"currentPage": currentPage,"userId" : userId},
  30. type : "post",
  31. dataType : "json",
  32. async:false, // 如果为异步加载无法给分页标签绑定事件(执行js的时候ajax数据还未加载完成),如果用异步加载需要使用live动态绑定
  33. success : function (data)
  34. {
  35. dealData(data);
  36. dealTable(data);
  37. dealPage(data);
  38. },
  39. error : function(XMLHttpRequest, textStatus, errorThrown)
  40. {
  41. alert(textStatus);
  42. stateCode(XMLHttpRequest);
  43. }
  44. });
  45. }
  46. // 页码展示
  47. function dealPage(data)
  48. {
  49. var str = "";
  50. for ( var i = 1; i <= data.totalPage; i++)
  51. {
  52. var strRed = "";
  53. var strOther = "";
  54. //str += "
  55. "+i+" "; if (i == data.currentPage) { strRed = " "+i+" "; } else { strOther = " "+i+" "; } str = str + strRed + strOther; } var str1 = " "; var str2 = " "+data.totalCount+" "; var str3 = " "; var str4 = ""; var str5 = ""; if (data.totalPage > 0) { str4 = " "; str5 = " "; } var strAll = str1 + str2 + str3 + str4 + str + str5; $("#page").html(strAll); }
  56. // jquery实现动态绑定 分页
  57. $("#page").off("click").on("click","li[page = 'page']",function()
  58. {
  59. //alert("click");
  60. currentPage = $(this).attr("pageNo");
  61. findForAjax(currentPage,userId);
  62. });
  63. // 用户账单总行数
  64. Integer totalCount = billsServiceImpl.findTotalConut(userId);
  65. // 开始行
  66. Integer startRow = null;
  67. if (currentPage == null)
  68. {
  69. startRow = (Constant.bill.CURRENTPAGE - 1)*PAGESIZE;
  70. }
  71. else
  72. {
  73. // 开始行
  74. startRow = (currentPage - 1)*PAGESIZE;
  75. }
  76. // 总页数
  77. Integer totalPage = (totalCount % PAGESIZE == 0 ? totalCount/PAGESIZE : totalCount/PAGESIZE + 1);
  78. Map
  79. param = new HashMap
  80. ();
  81. param.put("userId", userId);
  82. param.put("start", startRow);
  83. param.put("pageSize", PAGESIZE);
  84. List
  85. bills = billsServiceImpl.findBillsForPage(param);
  86. model.put("bills", bills);
  87. model.put("totalCount", totalCount);
  88. model.put("pageSize", PAGESIZE);
  89. model.put("currentPage", currentPage);
  90. model.put("totalPage", totalPage);
  91. select b.*, t.id tid, t.name, t.userId from bills b, bill_type t where b.typeId = t.id and b.userId = #{userId} order by b.billTime desc limit #{start} , #{pageSize}

发表评论

表情:
评论列表 (有 0 条评论,347人围观)

还没有评论,来说两句吧...

相关阅读

    相关 SSM实现查询

    前言 > 分页基本上是我们项目中所必须的功能,当数据量过大时,可能会导致各种各样的问题发生,例如:服务器资源被耗尽,因数据传输量过大而使处理超时,等等。最终都会导致查询无

    相关 Layui + ssm

    做后台就会涉及到表格数据,当数据多的时候,就要使用分页来显示,这样就显得比较美观。分页确实有效,但它一定会加大系统的复杂度,如果数据量少的话可以不用分页,但是对于企业信息系统来

    相关 ssm查询

    引言:基于ssm框架下,利用Mybaits插件PageHelper进行分页查询,可以省去大量繁琐的代码,操作起来更为方便, 1、数据库表的设计 ![70][] ---