• 通用分页02(前端)


    今天所要讲的是关于前端的通用分页

    目录

    一、改造pagebean

    二、分页查询


    一、改造pagebean

    所需条件:

            ①需要新增变量保存上一次查询条件;

            ②需要新增变量保存上一次请求地址;比如:http://localhost:8080/t280_page/book/search

            ③需要添加方法:获取最大页的页码;

            ④需要添加方法:获取下一页的页码;

            ⑤需要添加方法:获取上一页的页码;

            ⑥需要增加方法:初始化pagebean。

    PageBean类:

    1. package com.ycx.util;
    2. import java.util.HashMap;
    3. import java.util.Map;
    4. import javax.servlet.http.HttpServletRequest;
    5. /**
    6. * 分页工具类
    7. *
    8. */
    9. public class PageBean {
    10. private int page = 1;// 页码
    11. private int rows = 10;// 页大小
    12. private int total = 0;// 总记录数
    13. private boolean pagination = true;// 是否分页
    14. //  需要新增变量保存上一次请求地址;比如:http://localhost:8080/t280_page/book/search
    15. private String url;
    16. //  需要新增变量保存上一次查询条件
    17. private Map<String,String[]> parameterMap = new HashMap<>();
    18. //  需要添加方法:获取最大页的页码
    19. public int maxPage() {
    20. return this.total % this.rows == 0 ?
    21. this.total / this.rows
    22. : this.total / this.rows+1;
    23. }
    24. //  需要添加方法:获取上一页的页码;
    25. public int previousPage() {
    26. return this.page > 1 ? this.page-1 : this.page;
    27. }
    28. //  需要添加方法:获取下一页的页码
    29. public int nextPage() {
    30. return this.page < this.maxPage()?
    31. this.page+1:this.page;
    32. }
    33. //  需要增加方法:初始化pagebean
    34. public void setRequest(HttpServletRequest req) {
    35. this.setPage(req.getParameter("page"));
    36. this.setRows(req.getParameter("rows"));
    37. this.setPagination(req.getParameter("pagination"));
    38. this.setUrl(req.getRequestURI().toString());
    39. this.setParameterMap(req.getParameterMap());
    40. }
    41. private void setPagination(String pagination) {
    42. if(StringUtils.isNotBlank(pagination)) {
    43. this.setPagination(!"false".equals(pagination));
    44. }
    45. }
    46. private void setRows(String rows) {
    47. if(StringUtils.isNotBlank(rows)) {
    48. this.setRows(Integer.valueOf(rows));
    49. }
    50. }
    51. public void setPage(String page) {
    52. if(StringUtils.isNotBlank(page)) {
    53. // set自动生成的方法
    54. this.setPage(Integer.valueOf(page));
    55. }
    56. }
    57. public String getUrl() {
    58. return url;
    59. }
    60. public void setUrl(String url) {
    61. this.url = url;
    62. }
    63. public Map<String, String[]> getParameterMap() {
    64. return parameterMap;
    65. }
    66. public void setParameterMap(Map<String, String[]> parameterMap) {
    67. this.parameterMap = parameterMap;
    68. }
    69. public PageBean() {
    70. super();
    71. }
    72. public int getPage() {
    73. return page;
    74. }
    75. public void setPage(int page) {
    76. this.page = page;
    77. }
    78. public int getRows() {
    79. return rows;
    80. }
    81. public void setRows(int rows) {
    82. this.rows = rows;
    83. }
    84. public int getTotal() {
    85. return total;
    86. }
    87. public void setTotal(int total) {
    88. this.total = total;
    89. }
    90. public void setTotal(String total) {
    91. this.total = Integer.parseInt(total);
    92. }
    93. public boolean isPagination() {
    94. return pagination;
    95. }
    96. public void setPagination(boolean pagination) {
    97. this.pagination = pagination;
    98. }
    99. /**
    100. * 获得起始记录的下标
    101. *
    102. * @return
    103. */
    104. public int getStartIndex() {
    105. return (this.page - 1) * this.rows;
    106. }
    107. @Override
    108. public String toString() {
    109. return "PageBean [page=" + page + ", rows=" + rows + ", total=" + total + ", pagination=" + pagination
    110. + ", url=" + url + ", parameterMap=" + parameterMap + "]";
    111. }
    112. }

    然后新建一个 BookServlet :

    1. package com.ycx.web;
    2. import java.io.IOException;
    3. import java.util.Map;
    4. import javax.jws.WebService;
    5. import javax.servlet.ServletException;
    6. import javax.servlet.annotation.WebServlet;
    7. import javax.servlet.http.HttpServlet;
    8. import javax.servlet.http.HttpServletRequest;
    9. import javax.servlet.http.HttpServletResponse;
    10. import com.ycx.util.PageBean;
    11. @WebServlet("/book/search")
    12. public class BookServlet extends HttpServlet{
    13. @Override
    14. protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    15. doPost(req, resp);
    16. }
    17. @Override
    18. protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    19. PageBean pageBean=new PageBean();
    20. pageBean.setRequest(req);
    21. req.setAttribute("pagebean", pageBean);
    22. req.getRequestDispatcher("/bookList.jsp").forward(req, resp);
    23. }
    24. }

    bookList.jsp代码:

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    4. <html>
    5. <head>
    6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    7. <title>Insert title here</title>
    8. </head>
    9. <body>
    10. ${pagebean }
    11. </body>
    12. </html>

     运行结果:

     然后使用debug查看:

    二、分页查询

    接着我们以一个书籍列表为案例:

    bookList.jsp代码:

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    4. <html>
    5. <head>
    6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    7. <link
    8. href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.css"
    9. rel="stylesheet">
    10. <script
    11. src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.js"></script>
    12. <title>书籍列表</title>
    13. <style type="text/css">
    14. .page-item input {
    15. padding: 0;
    16. width: 40px;
    17. height: 100%;
    18. text-align: center;
    19. margin: 0 6px;
    20. }
    21. .page-item input, .page-item b {
    22. line-height: 38px;
    23. float: left;
    24. font-weight: 400;
    25. }
    26. .page-item.go-input {
    27. margin: 0 10px;
    28. }
    29. </style>
    30. </head>
    31. <body>
    32. <form class="form-inline"
    33. action="${pageContext.request.contextPath }/book.action" method="post">
    34. <div class="form-group mb-2">
    35. <input type="text" class="form-control-plaintext" name="bname"
    36. placeholder="请输入书籍名称">
    37. </div>
    38. <button type="submit" class="btn btn-primary mb-2">查询</button>
    39. </form>
    40. <table class="table table-striped ">
    41. <thead>
    42. <tr>
    43. <th scope="col">书籍ID</th>
    44. <th scope="col">书籍名</th>
    45. <th scope="col">价格</th>
    46. </tr>
    47. </thead>
    48. <tbody>
    49. <tr>
    50. <td>1</td>
    51. <td>圣墟第1章</td>
    52. <td>1</td>
    53. </tr>
    54. <tr>
    55. <td>1</td>
    56. <td>圣墟第1章</td>
    57. <td>1</td>
    58. </tr>
    59. </tbody>
    60. </table>
    61. </body>
    62. </html>

     目前我们的页面效果是这样的,数据暂时都是定死的,并且无法查看上一页、下一页、尾页:

    前端首先要显示界面,自己建一个tag标签包(PageTag),然后通过上节课学得知识自定义标签来写一个page标签,最后在index界面中直接写出自己定义的标签就行。

    接下来要给它新建一个PageTag类:

    1. package com.ycx.tag;
    2. import java.util.Map;
    3. import java.util.Map.Entry;
    4. import java.util.Set;
    5. import com.ycx.util.PageBean;
    6. import javax.servlet.jsp.JspException;
    7. import javax.servlet.jsp.JspWriter;
    8. import javax.servlet.jsp.tagext.BodyTagSupport;
    9. public class PageTag extends BodyTagSupport{
    10. private PageBean pageBean;
    11. public PageBean getPageBean() {
    12. return pageBean;
    13. }
    14. public void setPageBean(PageBean pageBean) {
    15. this.pageBean = pageBean;
    16. }
    17. @Override
    18. public int doStartTag() throws JspException {
    19. JspWriter out = pageContext.getOut();
    20. try {
    21. out.print(toHTML());
    22. } catch (Exception e) {
    23. // TODO Auto-generated catch block
    24. e.printStackTrace();
    25. }
    26. return super.doStartTag();
    27. }
    28. private String toHTML() {
    29. StringBuffer sb=new StringBuffer();
    30. // 隐藏的form表单,作用保存上一次查询条件
    31. sb.append("<form action='"+pageBean.getUrl()+"' id='pageBeanForm' method='post'>");
    32. sb.append(" <input type='hidden' name='page' value=''>");
    33. Map<String, String[]> parameterMap = pageBean.getParameterMap();
    34. if(parameterMap != null && parameterMap.size() > 0) {
    35. Set<Entry<String, String[]>> entrySet = parameterMap.entrySet();
    36. for (Entry<String, String[]> entry : entrySet) {
    37. String key = entry.getKey();// name/likes/page/rows
    38. String[] values = entry.getValue();
    39. if(!"page".equals(key)) {
    40. for (String value : values) {
    41. sb.append(" <input type='hidden' name='"+key+"' value='"+value+"'>");
    42. }
    43. }
    44. }
    45. }
    46. sb.append("</form>");
    47. // 分页条
    48. sb.append("<ul class='pagination justify-content-center'>");
    49. sb.append(" <li class='page-item "+(pageBean.getPage() == 1 ? "disabled" : "")+"'><a class='page-link'");
    50. sb.append(" href='javascript:gotoPage(1)'>首页</a></li>");
    51. sb.append(" <li class='page-item "+(pageBean.getPage() == 1 ? "disabled" : "")+"'><a class='page-link'");
    52. sb.append(" href='javascript:gotoPage("+pageBean.previousPage()+")'>&lt;</a></li>");
    53. sb.append(" <li class='page-item active'><a class='page-link' href='#'>"+pageBean.getPage()+"</a></li>");
    54. sb.append(" <li class='page-item "+(pageBean.getPage() == pageBean.maxPage() ? "disabled" : "")+"'><a class='page-link' href='javascript:gotoPage("+pageBean.nextPage()+")'>&gt;</a></li>");
    55. sb.append(" <li class='page-item "+(pageBean.getPage() == pageBean.maxPage() ? "disabled" : "")+"'><a class='page-link' href='javascript:gotoPage("+pageBean.maxPage()+")'>尾页</a></li>");
    56. sb.append(" <li class='page-item go-input'><b>到第</b><input class='page-link'");
    57. sb.append(" type='text' id='skipPage' name='' /><b>页</b></li>");
    58. sb.append(" <li class='page-item go'><a class='page-link'");
    59. sb.append(" href='javascript:skipPage()'>确定</a></li>");
    60. sb.append(" <li class='page-item'><b>共"+pageBean.getTotal()+"条</b></li>");
    61. sb.append("</ul>");
    62. // 分页js代码
    63. sb.append("<script type='text/javascript'>");
    64. sb.append(" function gotoPage(page) {");
    65. sb.append(" document.getElementById('pageBeanForm').page.value = page;");
    66. sb.append(" document.getElementById('pageBeanForm').submit();");
    67. sb.append(" }");
    68. sb.append(" function skipPage() {");
    69. sb.append(" var page = document.getElementById('skipPage').value;");
    70. sb.append(" if (!page || isNaN(page) || parseInt(page) < 1");
    71. sb.append(" || parseInt(page) > "+pageBean.maxPage()+") {");
    72. sb.append(" alert('请输入1~"+pageBean.maxPage()+"的数字');");
    73. sb.append(" return;");
    74. sb.append(" }");
    75. sb.append(" gotoPage(page);");
    76. sb.append(" }");
    77. sb.append("</script>");
    78. return sb.toString();
    79. }
    80. }

    继承 BodyTagSupport类,用stringbuffer中的append方法来实现页面展示效果。

    最后在index中写好    <y:page></y:page>即可。

    ycx.tld代码:

    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    5. version="2.0">
    6. <description>JSTL 1.1 core library</description>
    7. <display-name>JSTL core</display-name>
    8. <tlib-version>1.1</tlib-version>
    9. <short-name>y</short-name>
    10. <uri>http://ycx.com</uri>
    11. <validator>
    12. <description>
    13. Provides core validation features for JSTL tags.
    14. </description>
    15. <validator-class>
    16. org.apache.taglibs.standard.tlv.JstlCoreTLV
    17. </validator-class>
    18. </validator>
    19. <tag>
    20. <name>page</name>
    21. <tag-class>com.ycx.tag.PageTag</tag-class>
    22. <body-content>JSP</body-content>
    23. <attribute>
    24. <name>pageBean</name>
    25. <required>true</required>
    26. <rtexprvalue>true</rtexprvalue>
    27. </attribute>
    28. </tag>
    29. </taglib>

     分页得核心思想当点击下一页时,有许多参数是不变的,比如像名字,行数,以及总页数,但是其中有一个参数要变,那就是page(页数)

    优化PageBean代码:

    1. package com.ycx.util;
    2. import java.util.HashMap;
    3. import java.util.Map;
    4. import javax.servlet.http.HttpServletRequest;
    5. /**
    6. * 分页工具类
    7. *
    8. */
    9. public class PageBean {
    10. private int page = 1;// 页码
    11. private int rows = 10;// 页大小
    12. private int total = 0;// 总记录数
    13. private boolean pagination = true;// 是否分页
    14. //  需要新增变量保存上一次请求地址;比如:http://localhost:8080/t280_page/book/search
    15. private String url;
    16. //  需要新增变量保存上一次查询条件
    17. private Map<String,String[]> parameterMap = new HashMap<>();
    18. //  需要添加方法:获取最大页的页码
    19. public int maxPage() {
    20. return this.total % this.rows == 0 ?
    21. this.total / this.rows
    22. : this.total / this.rows+1;
    23. }
    24. //  需要添加方法:获取上一页的页码;
    25. public int previousPage() {
    26. return this.page > 1 ? this.page-1 : this.page;
    27. }
    28. //  需要添加方法:获取下一页的页码
    29. public int nextPage() {
    30. return this.page < this.maxPage()?
    31. this.page+1:this.page;
    32. }
    33. //  需要增加方法:初始化pagebean
    34. public void setRequest(HttpServletRequest req) {
    35. this.setPage(req.getParameter("page"));
    36. this.setRows(req.getParameter("rows"));
    37. this.setPagination(req.getParameter("pagination"));
    38. this.setUrl(req.getRequestURI().toString());
    39. this.setParameterMap(req.getParameterMap());
    40. }
    41. private void setPagination(String pagination) {
    42. if(StringUtils.isNotBlank(pagination)) {
    43. this.setPagination(!"false".equals(pagination));
    44. }
    45. }
    46. private void setRows(String rows) {
    47. if(StringUtils.isNotBlank(rows)) {
    48. this.setRows(Integer.valueOf(rows));
    49. }
    50. }
    51. public void setPage(String page) {
    52. if(StringUtils.isNotBlank(page)) {
    53. // set自动生成的方法
    54. this.setPage(Integer.valueOf(page));
    55. }
    56. }
    57. public String getUrl() {
    58. return url;
    59. }
    60. public void setUrl(String url) {
    61. this.url = url;
    62. }
    63. public Map<String, String[]> getParameterMap() {
    64. return parameterMap;
    65. }
    66. public void setParameterMap(Map<String, String[]> parameterMap) {
    67. this.parameterMap = parameterMap;
    68. }
    69. public PageBean() {
    70. super();
    71. }
    72. public int getPage() {
    73. return page;
    74. }
    75. public void setPage(int page) {
    76. this.page = page;
    77. }
    78. public int getRows() {
    79. return rows;
    80. }
    81. public void setRows(int rows) {
    82. this.rows = rows;
    83. }
    84. public int getTotal() {
    85. return total;
    86. }
    87. public void setTotal(int total) {
    88. this.total = total;
    89. }
    90. public void setTotal(String total) {
    91. this.total = Integer.parseInt(total);
    92. }
    93. public boolean isPagination() {
    94. return pagination;
    95. }
    96. public void setPagination(boolean pagination) {
    97. this.pagination = pagination;
    98. }
    99. /**
    100. * 获得起始记录的下标
    101. *
    102. * @return
    103. */
    104. public int getStartIndex() {
    105. return (this.page - 1) * this.rows;
    106. }
    107. @Override
    108. public String toString() {
    109. return "PageBean [page=" + page + ", rows=" + rows + ", total=" + total + ", pagination=" + pagination
    110. + ", url=" + url + ", parameterMap=" + parameterMap + "]";
    111. }
    112. }

    紧接着在bookList.jsp内导入我的y标签和c标签:

    1. <%@taglib uri="http://ycx.com" prefix="y" %>
    2. <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

     接着写一个BookServlet:

    1. package com.ycx.web;
    2. import java.io.IOException;
    3. import java.util.List;
    4. import java.util.Map;
    5. import javax.jws.WebService;
    6. import javax.servlet.ServletException;
    7. import javax.servlet.annotation.WebServlet;
    8. import javax.servlet.http.HttpServlet;
    9. import javax.servlet.http.HttpServletRequest;
    10. import javax.servlet.http.HttpServletResponse;
    11. import com.ycx.dao.BookDao;
    12. import com.ycx.entity.Book;
    13. import com.ycx.util.PageBean;
    14. @WebServlet("/book/search")
    15. public class BookServlet extends HttpServlet{
    16. @Override
    17. protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    18. doPost(req, resp);
    19. }
    20. @Override
    21. protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    22. // req.getParameter("name");
    23. // req.getParameterValues("likes");
    24. <input name="aa" value="">
    25. // Map<String, String[]> parameterMap = req.getParameterMap();//name
    26. //
    27. PageBean pageBean=new PageBean();
    28. pageBean.setRequest(req);
    29. BookDao bookDao=new BookDao();
    30. Book book=new Book();
    31. book.setBname(req.getParameter("bname"));
    32. try {
    33. List<Book> books = bookDao.list2(book, pageBean);
    34. req.setAttribute("books", books);
    35. } catch (Exception e) {
    36. // TODO Auto-generated catch block
    37. e.printStackTrace();
    38. }
    39. req.setAttribute("pagebean", pageBean);
    40. req.getRequestDispatcher("/bookList.jsp").forward(req, resp);
    41. }
    42. }

    再利用c:forEach标签把数据遍历出来,展示在页面上去,

    bookList.jsp代码:

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. <%@taglib uri="http://ycx.com" prefix="y" %>
    4. <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    5. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    6. <html>
    7. <head>
    8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    9. <link
    10. href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.css"
    11. rel="stylesheet">
    12. <script
    13. src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.js"></script>
    14. <title>书籍列表</title>
    15. <style type="text/css">
    16. .page-item input {
    17. padding: 0;
    18. width: 40px;
    19. height: 100%;
    20. text-align: center;
    21. margin: 0 6px;
    22. }
    23. .page-item input, .page-item b {
    24. line-height: 38px;
    25. float: left;
    26. font-weight: 400;
    27. }
    28. .page-item.go-input {
    29. margin: 0 10px;
    30. }
    31. </style>
    32. </head>
    33. <body>
    34. <form class="form-inline"
    35. action="${pageContext.request.contextPath }/book/search" method="post">
    36. <div class="form-group mb-2">
    37. <input type="text" class="form-control-plaintext" name="bname"
    38. placeholder="请输入书籍名称">
    39. </div>
    40. <button type="submit" class="btn btn-primary mb-2">查询</button>
    41. </form>
    42. <table class="table table-striped ">
    43. <thead>
    44. <tr>
    45. <th scope="col">书籍ID</th>
    46. <th scope="col">书籍名</th>
    47. <th scope="col">价格</th>
    48. </tr>
    49. </thead>
    50. <tbody>
    51. <c:forEach items="${books }" var="b">
    52. <tr>
    53. <td>${b.bid }</td>
    54. <td>${b.bname }</td>
    55. <td>${b.price }</td>
    56. </tr>
    57. </c:forEach>
    58. </tbody>
    59. </table>
    60. <y:page pageBean="${pagebean }"></y:page>
    61. </body>
    62. </html>

    运行效果如下:

     但是我们还面临一个问题,就是搜索时乱码

    比如搜索“圣墟”,如下图所示:

     搜索出来是乱码的情况

    那么我们就要去解决,我们需在EncodingFiter类里面去处理:

    1. package com.ycx.util;
    2. import java.io.IOException;
    3. import java.util.Iterator;
    4. import java.util.Map;
    5. import java.util.Set;
    6. import javax.servlet.Filter;
    7. import javax.servlet.FilterChain;
    8. import javax.servlet.FilterConfig;
    9. import javax.servlet.ServletException;
    10. import javax.servlet.ServletRequest;
    11. import javax.servlet.ServletResponse;
    12. import javax.servlet.annotation.WebFilter;
    13. import javax.servlet.http.HttpServletRequest;
    14. import javax.servlet.http.HttpServletResponse;
    15. /**
    16. * 中文乱码处理
    17. *
    18. */
    19. @WebFilter("/book/*")
    20. public class EncodingFiter implements Filter {
    21. private String encoding = "UTF-8";// 默认字符集
    22. public EncodingFiter() {
    23. super();
    24. }
    25. public void destroy() {
    26. }
    27. public void doFilter(ServletRequest request, ServletResponse response,
    28. FilterChain chain) throws IOException, ServletException {
    29. HttpServletRequest req = (HttpServletRequest) request;
    30. HttpServletResponse res = (HttpServletResponse) response;
    31. // 中文处理必须放到 chain.doFilter(request, response)方法前面
    32. res.setContentType("text/html;charset=" + this.encoding);
    33. if (req.getMethod().equalsIgnoreCase("post")) {
    34. req.setCharacterEncoding(this.encoding);
    35. } else {
    36. Map map = req.getParameterMap();// 保存所有参数名=参数值(数组)的Map集合
    37. Set set = map.keySet();// 取出所有参数名
    38. Iterator it = set.iterator();
    39. while (it.hasNext()) {
    40. String name = (String) it.next();
    41. String[] values = (String[]) map.get(name);// 取出参数值[注:参数值为一个数组]
    42. for (int i = 0; i < values.length; i++) {
    43. values[i] = new String(values[i].getBytes("ISO-8859-1"),
    44. this.encoding);
    45. }
    46. }
    47. }
    48. chain.doFilter(request, response);
    49. }
    50. public void init(FilterConfig filterConfig) throws ServletException {
    51. String s = filterConfig.getInitParameter("encoding");// 读取web.xml文件中配置的字符集
    52. if (null != s && !s.trim().equals("")) {
    53. this.encoding = s.trim();
    54. }
    55. }
    56. }

    我们再去用DeBug测试,搜索“圣墟”:

     就解决了~

                                                                    首页:

    尾页: 

     总结:通用分页把它简单化就分成前端和后台,其中公用的写到一个类里面就能减少代码量和大量时间,要抓住核心思想,这样才能事半功倍!我们下期再见叭~

  • 相关阅读:
    vue中使用echarts渐变柱状图 Cannot read properties of undefined (reading ‘graphic‘)解决方法
    Android 10 分区存储
    为控制器生成OpenAPI注释
    IPD流程概要
    麻了,别再为难软件测试员了
    Android打造专有hook,让不规范的代码扼杀在萌芽之中
    【JS】实现 Promise 的并发数控制
    9 网关的作用
    Redis原理
    回收站永久删除了如何恢复正常?
  • 原文地址:https://blog.csdn.net/weixin_65808248/article/details/125414711