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

相关推荐
代码小将1 小时前
Leetcode209做题笔记
java·笔记·算法
专注_每天进步一点点1 小时前
idea 启动Springboot项目在编译阶段报错:java: OutOfMemoryError: insufficient memory
java·spring boot·intellij-idea
dhxhsgrx2 小时前
PYTHON训练营DAY25
java·开发语言·python
不知几秋3 小时前
数字取证-内存取证(volatility)
java·linux·前端
chxii6 小时前
5java集合框架
java·开发语言
weixin_545019327 小时前
微信小程序智能商城系统(uniapp+Springboot后端+vue管理端)
spring boot·微信小程序·uni-app
yychen_java7 小时前
R-tree详解
java·算法·r-tree
JANYI20187 小时前
嵌入式设计模式基础--C语言的继承封装与多态
java·c语言·设计模式
xrkhy8 小时前
反射, 注解, 动态代理
java
Ten peaches8 小时前
Selenium-Java版(操作元素)
java·selenium·测试工具·html