pagehelper的使用
先上官方网站: https://pagehelper.github.io/
这是一个分页的工具类,使用起来非常的简单,方便,并且支持任何复杂的单表、多表分页
在maven中添加依赖
在 pom.xml 中添加如下依赖:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version><!--latest version--></version>
</dependency>
最新版本请到官网查看,当然用pagehelper的前提是有mybatis
配置项目语言
在项目配置文件application.properties
(有的项目是application.yml
,并不影响),配置pagehelpe
r方言为mysql
pagehelper.helper-dialect=mysql
业务逻辑代码
十分简单,仅需指定当前页数,然后你 的下一个SQL就会返回指定的数据 ,用PageInfo<T>
接受
前端
作为参考,这是我的前端代码
实现了翻页以及首尾页的跳转