气死老子了,每次做分页的是都要百度一下。
语法
select * from student limit 0,2
0
:要查询的起始行-索引位置从0开始计算,即表中的第一行对应的是索引0。
2
:要查询的行数。
分页查询公式
:index(索引)=(currentPage(当前页码)-1) * pageSize(每页页数)
PageHelper
//jdk8 lambda用法,countryMapper对应要操作的country表。
Page<Country> page = PageHelper.startPage(1, 10).doSelectPage(()-> countryMapper.selectGroupBy());
Page<HomeOperationHis>PageHelper.startPage(pageNum,pageSize).doSelectPage(()->operationMapper.selectByExample(criteria));