1.PageHelper
依赖包package com.github.pagehelper
PageHelper.startPage(pageNum, pageSize);
String year = "2018";
String month = "11";
List<EquityRelation> equityRelations = baseMapper.getRelationCompanys(year, month);
return new PageInfo<EquityRelation>(equityRelations );
PageHelper.startPage(pageNum, pageSize); 挖进去,
public static <E> Page<E> startPage(int pageNum, int pageSize, boolean count, Boolean reasonable, Boolean pageSizeZero) {
Page<E> page = new Page(pageNum, pageSize, count);
page.setReasonable(reasonable);
page.setPageSizeZero(pageSizeZero);
Page<E> oldPage = getLocalPage();
if (oldPage != null && oldPage.isOrderByOnly()) {
page.setOrderBy(oldPage.getOrderBy());
}
setLocalPage(page);
return page;
}
setLocalPage(page);挖进去
pageNum,pageSize
将参数 放到如下的ThreadLocal 中
ThreadLocal<Page> LOCAL_PAGE = new ThreadLocal();
运用MyBatis插件,(MyBatis插件有四个)
https://blog.csdn.net/cuihaiyang/article/details/75452539
自定义类实现org.apache.ibatis.plugin.Interceptor接口,
在自定义类中实现, PageInterceptor(从下面项目里搞出来的),
http://git.oschina.net/free/Mybatis_PageHelper
在逻辑if (!dialect.skip(ms, parameter, rowBounds)) 里,
将page取出,
Page page = PageHelper.getLocalPage();