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 官网

相关推荐
Algorithm15764 分钟前
谈谈接口和抽象类有什么区别?
java·开发语言
细心的莽夫34 分钟前
SpringCloud 微服务复习笔记
java·spring boot·笔记·后端·spring·spring cloud·微服务
264玫瑰资源库2 小时前
问道数码兽 怀旧剧情回合手游源码搭建教程(反查重优化版)
java·开发语言·前端·游戏
pwzs2 小时前
Java 中 String 转 Integer 的方法与底层原理详解
java·后端·基础
东阳马生架构2 小时前
Nacos简介—2.Nacos的原理简介
java
普if加的帕2 小时前
java Springboot使用扣子Coze实现实时音频对话智能客服
java·开发语言·人工智能·spring boot·实时音视频·智能客服
爱喝一杯白开水3 小时前
SpringMVC从入门到上手-全面讲解SpringMVC的使用.
java·spring·springmvc
王景程3 小时前
如何测试短信接口
java·服务器·前端
〆、风神3 小时前
Spring Boot 整合 Lock4j + Redisson 实现分布式锁实战
spring boot·分布式·后端
zhang23839061544 小时前
IDEA add gitlab account 提示
java·gitlab·intellij-idea·idea