spring boot+thymeleaf+semantic ui 分页

参考:

https://my.oschina.net/ayyao/blog/898041

后端 springboot 使用:

com.github.pagehelper.PageInfo,作为分页对象

<!--引入分页插件-->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.12</version>
</dependency>

controller里代码:

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

String orderBy = "id desc";
PageHelper.startPage(pageNum, 10, orderBy);
List<User> users = userService.list();
if (users != null) {
    PageInfo<Type> pageInfo = new PageInfo<>(types);
    model.addAttribute("pageInfo", pageInfo);
}

前端分页代码:


<tfoot>
  <tr>
    <th colspan="6" >

      <!--分页条 begin-->
      <div class="ui left floated pagination mini menu">
        <!-- 首页 -->
        <a th:href="@{/sss/userapi(pageNum=1)}" class="icon item" >首页</a>
        <!-- 上一页previous -->
        <a th:if="${pageInfo.hasPreviousPage}" class="icon item" th:classappend="${pageInfo.pageNum}==0 ? 'disabled' : ''"
           th:href="@{/sss/userapi(pageNum=${pageInfo.prePage})}">
          <i class="angle left icon">上一页</i>
        </a>
        <!-- 中间页面1-10页面-->
        <div th:each="p : ${pageInfo.navigatepageNums}">
          <a class="icon item" th:classappend="${pageInfo.pageNum}==${p} ? 'disabled' : ''"
             th:href="@{/sss/userapi(pageNum=${p})}">
            <i th:text="${p}"></i>
          </a>
        </div>

        <!-- 下一页next -->
        <a th:if="${pageInfo.hasNextPage}" class="icon item"
           th:href="@{/sss/userapi(pageNum=${pageInfo.nextPage})}">
          下一页<i class="angle right icon"></i>
        </a>
        <!-- 尾页 -->
        <a th:href="@{/sss/userapi(pageNum=${pageInfo.pages})}" class="icon item" >尾页</a>
      </div>
      <!--分页条 end-->

    </th>
  </tr>
</tfoot>

首页、中间页、尾页样式:

其他:

Thymeleaf循环语句_thymeleaf 循环_苦海无边,不能上岸的博客-CSDN博客

Table | Semantic UI 官网

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值