41d0cab97a27e94505660a2c64a1ac5e5034f721.svn-base 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.yihu.utils;
  2. import javax.servlet.http.HttpServletRequest;
  3. /**
  4. * 分页参数
  5. * @author chenzhibin <br> 2017-5-9 下午18:12:30
  6. */
  7. public class Pager {
  8. public HttpServletRequest request;
  9. public int page = 1;//当前页
  10. public int start = 0;//从第一条记录开始,也就是0
  11. public int pageSize = 10;//每页10条记录
  12. public static int exportpageSize=1000;
  13. public Pager(int page,int pageSize) {
  14. super();
  15. Object oRows = pageSize;
  16. if (oRows == null || "".equals(oRows.toString())) {
  17. this.pageSize = 10;
  18. } else {
  19. this.pageSize = Integer.valueOf(oRows.toString());
  20. }
  21. Object oPage = page;
  22. if (oPage == null || "".equals(oPage)) {
  23. this.start = 0;
  24. } else {
  25. if (Integer.valueOf(oPage.toString()) <= 1) {
  26. this.start = 0;
  27. } else {
  28. this.start = (Integer.valueOf(oPage.toString()) - 1) * pageSize;
  29. }
  30. }
  31. }
  32. /**
  33. * @param request
  34. */
  35. public Pager(HttpServletRequest request) {
  36. super();
  37. this.request = request;
  38. Object oRows = request.getParameter("rows");
  39. if (oRows == null || "".equals(oRows.toString())) {
  40. this.pageSize = 10;
  41. } else {
  42. this.pageSize = Integer.valueOf(oRows.toString());
  43. }
  44. Object oPage = request.getParameter("page");
  45. if (oPage == null || "".equals(oPage)) {
  46. this.start = 0;
  47. } else {
  48. if (Integer.valueOf(oPage.toString()) <= 1) {
  49. this.start = 0;
  50. } else {
  51. this.start = (Integer.valueOf(oPage.toString()) - 1) * pageSize;
  52. }
  53. }
  54. }
  55. public Pager(HttpServletRequest request,boolean isExportPage) {
  56. super();
  57. this.request = request;
  58. Object oRows = request.getParameter("rows");
  59. if (isExportPage) {
  60. this.pageSize = 1000;
  61. } else {
  62. if (oRows == null || "".equals(oRows.toString())) {
  63. this.pageSize = 10;
  64. } else {
  65. this.pageSize = Integer.valueOf(oRows.toString());
  66. }
  67. }
  68. Object oPage = request.getParameter("page");
  69. if (oPage == null || "".equals(oPage)) {
  70. this.start = 0;
  71. } else {
  72. if (Integer.valueOf(oPage.toString()) <= 1) {
  73. this.start = 0;
  74. } else {
  75. this.start = (Integer.valueOf(oPage.toString()) - 1) * pageSize;
  76. }
  77. }
  78. }
  79. }