分页查询
分页查询
分页插件有很多
- 原始的limit进行1分页
- pageHelper第三方插件
- MybatisPlus内置插件
如何使用?
配置config
//分页插件
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
- 直接使用即可
//分页插件
@Test
public void testPage(){
//参数一:当前页
//参数二:页面大小
Page<User> objectPage = new Page<>(1, 5);//第1页,5行数据
mapper.selectPage(objectPage, null);//分页查询 条件为null
System.out.println(objectPage.getTotal());//获取总记录数
System.out.println(objectPage.getCurrent());//获取当前页
objectPage.getRecords();//获取数据
objectPage.getRecords().forEach(System.out::println);//打印输出
}

浙公网安备 33010602011771号