添加配置
分页查询
@Test void testPage(){ Page<User> page = new Page<>(1,5); userMapper.selectPage(page,null); page.getRecords().forEach(System.out::println); System.out.println("page.getCurrent():"+page.getCurrent()); System.out.println("page.getPages():"+page.getPages()); System.out.println("page.getSize():"+page.getSize()); System.out.println("page.getTotal():"+page.getTotal()); System.out.println("page.hasNext():"+page.hasNext()); System.out.println("page.hasPrevious():"+page.hasPrevious()); }
实现效果
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@719d35e8] User(id=1, name=JoneEdit, age=18, email=test1@baomidou.com, createTime=null, version=1) User(id=2, name=Jack, age=20, email=test2@baomidou.com, createTime=null, version=null) User(id=3, name=Tom, age=28, email=test3@baomidou.com, createTime=null, version=null) User(id=4, name=Sandy, age=21, email=test4@baomidou.com, createTime=null, version=null) User(id=5, name=Billie, age=24, email=test5@baomidou.com, createTime=null, version=null) page.getCurrent():1 page.getPages():2 page.getSize():5 page.getTotal():7 page.hasNext():true page.hasPrevious():false