使用分页插件PageHelper报类转换异常

报错信息:java.util.ArrayList cannot be cast to com.github.pagehelper.Page

产生原因:

PageHelper.startPage(pageNumber, pageSize);
List<String> userIdList = userRoleMapper.selectUserIdByRole();
List<Log> list = logDao.selectAllLog();
return (Page<Log>)list;

 在查询要返回的结果前还进行了一次数据库查询,调整为以下顺序后正确:

List<String> userIdList = userRoleMapper.selectUserIdByRole();
PageHelper.startPage(pageNumber, pageSize);
List<Log> list = logDao.selectAllLog();
return (Page<Log>)list;

猜你喜欢

转载自blog.csdn.net/Xuchunyan234/article/details/82185490