pagehelper的使用
知识点:使用pagehelper实现分页功能
参考资料github上:https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md
(1)不是maven项目,则需要下载引用pagehelper和jsqlparser两个jar包
http://repo1.maven.org/maven2/com/github/pagehelper/pagehelper/
http://repo1.maven.org/maven2/com/github/jsqlparser/jsqlparser/0.9.5/
maven项目只需,直接在pom.xml中引入依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>最新版本</version>
</dependency>
(2)在mybatis配置文件mybatis-config.xml中配置拦截器插件
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
</plugins>
(3)在代码中使用分页功能
例如:1.查询所有数据,然后分页
Page<Object> page=PageHelper.startPage(4, 1);//4为第4页,1为每页的页数
注意:紧跟着的第一个select方法会被分页
EmployeeMapper mapper = openSession.getMapper(EmployeeMapper.class);//查询所有数据
2.需要连续显示多少页
);
System.out.println("当前页码"+info.getPageNum());
System.out.println("总记录数"+info.getTotal());
System.out.println("每页记录数"+info.getPageSize());
System.out.println("总页码"+page.getPages());
System.out.println("连续显示的页码");
int[] nums=info.getNavigatepageNums();
for (int i : nums) {
System.out.println(i);
}
效果:

源码:https://github.com/shuaishuaihand/pagehelper.git
pagehelper的使用的更多相关文章
- PageHelper简单实用
mybatis-config.xml配置如下: <!-- 分页插件 --> <plugins> <plugin interceptor="com.github. ...
- springboot使用之二:整合mybatis(xml方式)并添加PageHelper插件
整合mybatis实在前面项目的基础上进行的,前面项目具体整合请参照springboot使用之一. 一.整合mybatis 整合mybatis的时候可以从mybatis官网下载mybatis官网整合的 ...
- 理解 Mybatis的分页插件 PageHelper
Mybatis + SpringMVC + Maven实现分页查询 (推荐采用的插件是PageHelper) 先看一下之前的这篇博客,这里推荐了 Mybatis 的分页方法. 按照上面的方法设置后,确 ...
- Spring + Mybatis 使用 PageHelper 插件分页
原文:http://www.cnblogs.com/yucongblog/p/5330886.html 先增加maven依赖: <dependency> <groupId>co ...
- Mybatis的分页插件PageHelper
Mybatis的分页插件PageHelper 项目地址:http://git.oschina.net/free/Mybatis_PageHelper 文档地址:http://git.oschina. ...
- mybatis分页插件PageHelper的使用(转)
Mybatis 的分页插件PageHelper-4.1.1的使用 Mybatis 的分页插件 PageHelper 项目地址:http://git.oschina.net/free/Mybatis_P ...
- MyBatis学习总结_17_Mybatis分页插件PageHelper
如果你也在用Mybatis,建议尝试该分页插件,这一定是最方便使用的分页插件. 分页插件支持任何复杂的单表.多表分页,部分特殊情况请看重要提示. 想要使用分页插件?请看如何使用分页插件. 物理分页 该 ...
- Spring集成PageHelper的简单用法
1.Maven依赖,注意使用PageHelper时的版本必须与Mybatis版本对应 <!-- 添加Mybatis依赖 --> <dependency> <groupId ...
- Mybatis分页插件PageHelper正确的用法(网上有2篇不够科学的文章)
今天下午在Mybatis项目中.实现分页.由于我是后加入项目中的,Leader用的是PageHelper这个组件.可是我在实际使用的过程中遇到了2个大问题. 1.p=2#comments" ...
- maven+springmvc+easyui+fastjson+pagehelper
1.maven配置 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...
随机推荐
- Quartz.net 基于配置的调度程序实践
1.Nuget 搜索并安装Quartz.net 2.3.3 2.添加配置到App.config <?xml version="1.0" encoding="utf ...
- 解决64位debian下无法安装ia32库的问题
原文地址:http://crunchbang.org/forums/viewtopic.php?pid=277918 因为64位debian源中并没有包括32位的软件包,所提安装ia32会提示依赖无法 ...
- Spark官方3 ---------Spark Streaming编程指南(1.5.0)
Design Patterns for using foreachRDD dstream.foreachRDD是一个强大的原语,允许将数据发送到外部系统.然而,了解如何正确有效地使用该原语很重要.避免 ...
- Python在运维工作中的经典应用之ansible
1.安装ansible wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo curl -o /e ...
- Incorrect key file for table ' '; try to repair it
场景:为有150W的数据表增加字段时,报错 解决:在my.ini配置临时目录configure tmpdir. Where MySQL Stores Temporary Files
- ObjectDetection中的一些名词中英文对照
mAP:mean Average Precision,平均精确度 recall rate:召回率 Loss Function Anchro
- 过程记录:搭建wordpress站点
过程记录:搭建wordpress站点 前提:现在aws中搭建好LNAMP环境和网络mysql数据库,即为下载的wdcp和aws的rds 1.获取WordPress安装包(中文版) https://cn ...
- 003-shell 传递参数
一.概述 可以在执行 Shell 脚本时,向脚本传递参数,脚本内获取参数的格式为:$n.n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推…… 二.实例 以下实例我们向 ...
- 新建虚拟机与本机ping不通(一招解决)
初始新建虚拟机或者复制虚拟机后,发现虚拟机能ping通内外网,但是本机无法ping通虚拟机,xshell也无法连接虚拟机 这时候就很头疼了,因为要上传很多文件到虚拟机上面 解决办法: 1.关闭虚拟机后 ...
- appium格式化循环点击