MybatisPlus分页
- 使用分页前先引用分页的拦截器
在配置类用引用mybatisplus的分页
@Configuration
public class MPConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
}
- 编写测试类
@Test
void testGetPage(){
IPage page = new Page(1,5);
bookDao.selectPage(page ,null);
//查询的数据集合
System.out.println(page.getRecords());
//查询的分页数量
System.out.println(page.getPages());
//当前所在分页
System.out.println(page.getCurrent());
//每页的大小数量
System.out.println(page.getSize());
//所有数据数量
System.out.println(page.getTotal());
}
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果

