<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.3.3</version> </dependency>
// 启动分页拦截器 configuration.addInterceptor(new PageInterceptor());
使用方式如下:
@Test public void testPage() { PageHelper.startPage(2, 2, false); PageHelper.orderBy("name"); List<Country> countries = countryMapper.selectAll(); Assert.isInstanceOf(Page.class, countries); }
分页功能需要借助 PageHelper 这个工具类,详细细节直接阅读 PageHelper 的源码即可,代码逻辑非常简单,想要正确使用并不困难。
参考:https://pagehelper.github.io/docs/howtouse/
Last updated 7 months ago