pom.xml如下:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.0</version>
</dependency>
<!-- 会自动引入jsqlparser0.9.5 ,如果没有,自己引入-->
mybatis插件配置:
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!--5.0以上不要配置这条-->
<!--<property name="dialect" value="mysql"></property>-->
</plugin>
</plugins>
然后代码正常调用即可:
public EUDataGridResult getContentList(int page, int rows,long categoryId) {
TbContentExample example=new TbContentExample();
TbContentExample.Criteria criteria=example.createCriteria();
criteria.andCategoryIdEqualTo(categoryId);
PageHelper.startPage(page,rows);
List<TbContent> list=contentMapper.selectByExample(example);
EUDataGridResult result=new EUDataGridResult();
result.setRows(list);
PageInfo<TbContent> pageInfo=new PageInfo<>(list);
result.setTotal(pageInfo.getTotal());
return result;
}