spring boot+thymeleaf+semantic ui 分页

参考:

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

后端 springboot 使用:

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

java 复制代码
<!--引入分页插件-->
<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);
}

前端分页代码:

html 复制代码
<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 官网

相关推荐
Flittly4 分钟前
【SpringAIAlibaba新手村系列】(9)Text to Image 文本生成图像技术
java·spring boot·agent
Flittly5 分钟前
【SpringAIAlibaba新手村系列】(10)Text to Voice 文本转语音技术
java·spring boot·agent
JoshRen8 分钟前
springboot之集成Elasticsearch
spring boot·后端·elasticsearch
诸葛大钢铁8 分钟前
Java实现Excel文件合并
java·windows·excel
黎明丶之前12 分钟前
Spring Cloud Gateway 升级与 Bucket4j 限流实践
java·spring cloud
程序员木圭17 分钟前
05-告别逻辑混乱!Java 流程控制让代码学会"判断和循环"
java·后端
MmeD UCIZ21 分钟前
Skywalking介绍,Skywalking 9.4 安装,SpringBoot集成Skywalking
spring boot·后端·skywalking
ward RINL21 分钟前
Spring boot启动原理及相关组件
数据库·spring boot·后端
yaaakaaang21 分钟前
三、抽象工厂模式
java·抽象工厂模式
kongba00721 分钟前
复刻 Claude Code 项目御马术缰绳系统 harness engineering 落地蓝图
java·linux·服务器