Mybatis-plus使用分页进行分页查询
首先先配置配置文件
@Configuration public class MybatisPlusConfig { @Bean public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); } }
2.进行分页查询
@Test public void selectPage() { QueryWrapper<User> wrapper = new QueryWrapper<>(); wrapper.ge("age",26); Page<User> page = new Page<>(1, 2); IPage<User> userIPage = userMapper.selectPage(page, wrapper); System.out.println("总条数"+userIPage.getTotal()); System.out.println("总页数"+userIPage.getPages()); }
@Test public void selectPage() { QueryWrapper<User> wrapper = new QueryWrapper<>(); wrapper.ge("age",26); Page<User> page = new Page<>(1, 2); IPage<Map<String,Object>> userIPage = userMapper.selectMapsPage(page, wrapper); System.out.println("总条数"+userIPage.getTotal()); System.out.println("总页数"+userIPage.getPages()); }
本文来自博客园,作者:King-DA,转载请注明原文链接:https://www.cnblogs.com/qingmuchuanqi48/p/11920691.html