SpringBoot分页查询

176 阅读1分钟

分页查询

一、所需依赖

<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.12</version>
</dependency>

二、引入Service代码

public Object findPage(int pageNum, int pageSize) {
		//pageNum为起始页数,pageSize为每次查询多少页
		PageHelper.startPage(pageNum, pageSize);
		AccountExample example = new AccountExample();
		return mapper.selectByExample(example );
	}