分页的时候报错:
java.util.ArrayList cannot be cast to com.github.pagehelper.Page
以下两连接是我找bug解决方法的时候发现的自己没学过的知识,与本次bug无关。项目完了学习。wait,,me!
https://blog.csdn.net/qq_16517483/article/details/72803043#%E9%87%8D%E8%A6%81%E6%8F%90%E7%A4%BA
https://my.oschina.net/flags/blog/274000
然后,血的教训啊,,,,,找了半天 的bug
*
pageHelper只对紧跟着的查询结果进行分页!!!!!!!!
*
即使这个vo类里面的值还不是最全的返回给前台的数据,即使只有一部分是,那也得在这个查询结果前面写分页。之后的数据在处理的时候不需要分页。
PageHelper.startPage(bgClassListVO.getPage(), bgClassListVO.getLimit());
listClassVO=clazzMapper.findClassList(bgClassListVO);
List<BgClassListVO> listClassVO = new ArrayList<BgClassListVO>();
String clazzName=bgClassListVO.getClassName();
String clazzId=bgClassListVO.getClassId();
//如果时间为空赋初始值
if(null==bgClassListVO.getDate()) {
Date date=new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String dateNowStr = sdf.format(date);
bgClassListVO.setDate(dateNowStr);
PageHelper.startPage(bgClassListVO.getPage(), bgClassListVO.getLimit());
listClassVO=clazzMapper.findClassList(bgClassListVO);
}
try {
PageHelper.startPage(bgClassListVO.getPage(), bgClassListVO.getLimit());
listClassVO=clazzMapper.findClassList(bgClassListVO);
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
}``
List<ClazzGroup> list=new ArrayList<ClazzGroup>();
ClazzGroup clazzGroup=new ClazzGroup();
//轮流更新每个返回值里的小组数量,todayTaskRate和taskRate
for (int i = 0; i < listClassVO.size(); i++) {
//id
// String id0=listClassVO.get(i).getClazzGroupId();
// clazzGroup=clazzGroupMapper.selectByPrimaryKey(id0);
// PageHelper.startPage(bgClassListVO.getPage(), bgClassListVO.getLimit());
// list.add(clazzGroup);
//班级id
String id=listClassVO.get(i).getClassId();
//返回小组数量
listClassVO.get(i).setGroupNumber(clazzMapper.findGroupNumber(id));
//返回用户数量
listClassVO.get(i).setUserNumber(clazzMapper.findUserNumber(id));
//计算两个打卡率
Map map=new HashMap<>();
map=xwUtils.rate("0", id, listClassVO.get(i).getDate());
listClassVO.get(i).setTaskRate((String)map.get("rate"));
listClassVO.get(i).setTodayTaskRate((String)map.get("todayRate"));
}
return PageBaseVO.pageBack(listClassVO, listClassVO);
“`