maven集成分頁插件
添加依賴(缺一不可)
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>{pagehelper.version}</version>
</dependency>
Gradle集成分頁插件(注意兼容問題)
compile group: 'com.github.pagehelper', name: 'pagehelper', version: '5.1.8'
compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.2.10'
加好依賴后在application.properties中添加配置
pagehelper配置
pagehelper.helperDialect: mysql ##數(shù)據(jù)庫類型
pagehelper.reasonable: true
pagehelper.supportMethodsArguments: true
最后在serviceImpl中調(diào)用境输,返回格式可進(jìn)一步封裝
PageHelper.startPage(pageNum, pageSize);//pageNum 頁碼 pageSize 每頁顯示條數(shù)
List<Card> list = cardMapper.selectCardList(cardStatus, tel, cardNo, cardPwd, batchNo);
PageInfo<Card> pageInfo = new PageInfo<>(list);