mybatis分页插件PageHelper简单应用
--添加依賴(lài)
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.10</version>
</dependency>
<!--boot框架可引入該依賴(lài) 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
? ??#設(shè)置超過(guò)最大頁(yè)數(shù)不再返回?cái)?shù)據(jù)
? ??reasonable: false
? ??supportMethodsArguments: true
? ??params: count=countSql
? ??returnPageInfo: check
--簡(jiǎn)單使用(對(duì)于線程安全問(wèn)題可以參考官網(wǎng),注意對(duì)于大數(shù)據(jù)量,會(huì)用性能瓶頸)
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());
轉(zhuǎn)載于:https://www.cnblogs.com/sung1024/p/11178691.html
與50位技術(shù)專(zhuān)家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的mybatis分页插件PageHelper简单应用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [Ceoi2016|BZOJ4936]
- 下一篇: Python生成Windows可执行ex