在前端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}">2</option>
            <option value="4" th:selected="${pageInfo.size == 4}">4</option>
            <option value="6" th:selected="${pageInfo.size == 6}">6</option>
            <option value="8" th:selected="${pageInfo.size == 8}">8</option>
            <option value="10" th:selected="${pageInfo.size == 10}">10</option>
        </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>
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值