在前端thymeleaf中使用pagehelper进行分页及数据展示

https://blog.csdn.net/weixin_41866607/article/details/104181571
https://blog.csdn.net/qq_26975307/article/details/89088577
https://blog.csdn.net/yuzhiqiang_1/article/details/100553352

注:

[[${coder.user_name}]] 和 <span th:text="${coder.user_name}">span> 两种写法作用相同。
pagehelper插件的封装实体类pageInfo有两个属性prePage和nextPage,表示上一页的页码数和下一页的页码数,可以方便用来写上一页和下一页的功能。
thymeleaf给方法传入前台参数的写法:th:οnclick="pass([[${coder.coder_id}]])"

代码举例:

<tr th:each="coder,coderList:${pageInfo.list}">
    <td><input name="ids" type="checkbox">td>
    <td>
        [[${coder.user_name}]]
    td>
    <td>[[${coder.user_name}]]td>
    <td>[[${coder.user_name}]]td>
    <td>[[${coder.user_name}]]td>
    <td>[[${coder.user_name}]]td>
    <td>[[${coder.user_name}]]td>
    <td>[[${coder.user_name}]]td>
    <td><span th:text="${coder.coder_classification}">span>td>

    <td class="text-center">
        <button type="button" class="btn bg-olive btn-xs" th:onclick="pass([[${coder.coder_id}]])">通过button>
        <button type="button" class="btn bg-yellow btn-xs" th:onclick="fail([[${coder.coder_id}]])">不通过button>
    td>
tr>
<div class="pull-left">
    <div class="form-group form-inline">
        总共[[${pageInfo.pages}]]页,共[[${pageInfo.total}]]条数据。 每页
        <select class="form-control" id="changePageSize" onchange="changePageSize()">
            <option value="2" th:selected="${pageInfo.size == 2}">2option>
            <option value="4" th:selected="${pageInfo.size == 4}">4option>
            <option value="6" th:selected="${pageInfo.size == 6}">6option>
            <option value="8" th:selected="${pageInfo.size == 8}">8option>
            <option value="10" th:selected="${pageInfo.size == 10}">10option>
        select>div>
div>
<div class="box-tools pull-right">
    <ul class="pagination">
        <li>
            <a th:href="'/manage/findAll.do?page=1&size='+${pageInfo.pageSize}" aria-label="Previous">首页a>
        li>
        <li><a th:href="'/manage/findAll.do?page='+${pageInfo.prePage}+'&size='+${pageInfo.pageSize}">上一页a>li>
        <li th:each="nav:${pageInfo.navigatepageNums}">
            <a th:href="'/manage/findAll.do?page='+${nav}+'&size='+${pageInfo.pageSize}" th:text="${nav}" th:if="${nav != pageInfo.pageNum}">a>
            <span th:if="${nav == pageInfo.pageNum}" th:text="${nav}" >span>
        li>
        <li><a th:href="'/manage/findAll.do?page='+${pageInfo.nextPage}+'&size='+${pageInfo.pageSize}">下一页a>li>
        <li>
            <a th:href="'/manage/findAll.do?page='+${pageInfo.pages}+'&size='+${pageInfo.pageSize}" aria-label="Next">尾页a>
        li>
    ul>
div>

你可能感兴趣的:(springboot,pagehelper)