alamide的笔记库「 87篇笔记 」「 小破站已建 0 天啦 🐶 」


MyBatis PageHelper

2023-04-14, by alamide

Mybatis 分页插件,在这里

1.引入依赖

<dependency>
  <groupId>com.github.pagehelper</groupId>
  <artifactId>pagehelper-spring-boot-starter</artifactId>
  <version>1.4.6</version>
</dependency>

2.使用

PageHelper.startPage(page, pageSize);

final List<Employee> employeesByLikeUsername = employeeService.getEmployeesByLikeName(name);
PageInfo<Employee> pageInfo = new PageInfo<>(employeesByLikeUsername);
HashMap<String, Object> data = new HashMap<>();
data.put("records", pageInfo.getList());
data.put("total", pageInfo.getTotal());
Tags: Mybatis
~ belongs to alamide@163.com