mybatis分页插件PageHelper简单应用
--添加依賴
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.10</version>
</dependency>
<!--boot框架可引入該依賴 https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
--springboot配置(.yml)
#pagehelper
pagehelper:
? ??helperDialect: mysql
? ??#設置超過最大頁數不再返回數據
? ??reasonable: false
? ??supportMethodsArguments: true
? ??params: count=countSql
? ??returnPageInfo: check
--簡單使用(對于線程安全問題可以參考官網,注意對于大數據量,會用性能瓶頸)
int pageNum = Integer.parseInt(request.getParameter("pageNum"));
int pageSize = Integer.parseInt(request.getParameter("pageSize"));
PageHelper.startPage(pageNum,pageSize);
List<Map<String,Object>> list = getMarkersiteListNew(paramMap);
PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
Map<String,Object> listMap = new HashMap<>();
listMap.put("list",list);
listMap.put("pageNum",pageNum);
listMap.put("pageSize",pageSize/*list.size()*/);
listMap.put("total",pageInfo.getTotal());
轉載于:https://www.cnblogs.com/sung1024/p/11178691.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的mybatis分页插件PageHelper简单应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [Ceoi2016|BZOJ4936]
- 下一篇: 母板页中的图片路径及页面链接路径设置