关于PageHelper分页中当前页、每页数、总条数混乱问题
正确用法:
PageHelper.startPage(pageReq.getPage(), pageReq.getSize());
userList = userMapper.selectUserByOrgId(orgIdList, vo.getStatusList());
PageInfo pageInfo = new PageInfo<>(userList);
List<UserVo> list = new ArrayList<>();
list = userList.stream().map({
....
})
pageInfo.setList(list);
return pageInfo;
PageHelper.startPage(pageReq.getPage(), pageReq.getSize());
这个一定要直接放在mapper查询上方,不然传递当前页,每页数可能会有问题
PageInfo pageInfo = new PageInfo<>(userList);
userList查询的数据直接填充PageInfo
------
错误用法
PageHelper.startPage(pageReq.getPage(), pageReq.getSize());
userList = userMapper.selectUserByOrgId(orgIdList, vo.getStatusList());
List<UserVo> list = new ArrayList<>();
list = userList.stream().map({
....
})
PageInfo pageInfo = new PageInfo<>(list);//放在后面填充list,会导致PageInfo当前页、每页数被覆盖。
return pageInfo;