说明
使用 mybatis 查询之前,必须有 分页处理 PageHelper.startPage(),而且是一一对应
不能一句 PageHelper.startPage(),对应多条查询,否则查询分页失效
如下:
public PageInfo<Goods> mgrQueryList(String name,String startDate,String endDate,Integer status,int pageNum,int pageSize) throws Exception{
PageHelper.startPage(pageNum, pageSize, true);
//写在PageHelper.startPage下面,才会分页
List list=dao.mgrQueryList(name, startDate, endDate,status);
List list2=dao.mgrQueryList(name, startDate, endDate,status);//不会分页,除非再次调用PageHelper.startPage
//用PageInfo对结果进行包装,PageInfo包含非常全面的分页属性
PageInfo<Goods> pageInfo=new PageInfo<Goods>(list);
return pageInfo;
}