使用springboot分页查询
加入jar包依赖
<!--加入pagehelper包依赖-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
</dependency>
controller层代码
@RestController
public class UserController {
@Resource
private UserMapper userMapper;
@GetMapping("find")
public PageInfo<User> findAll(@RequestParam Integer currentPage, @RequestParam Integer pageSize){
PageHelper.startPage(currentPage,pageSize);
List<User> all=userMapper.findAll();
PageInfo<User> pageInfo=new PageInfo<>(all);
return pageInfo;
}
}