TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
List listPage = new ArrayList();
int index = 0;
if(request.getParameter("index") == null || request.getParameter("index").equals("")){
index = 1;
}else{
index = Integer.parseInt(request.getParameter("index"));
}
//定义总页数
int totalpage = 0;
if(problemList.size() == 0){
totalpage = 1;
}
if(problemList.size()%10 == 0){
totalpage = problemList.size()/10;
}
if(problemList.size()%10 != 0){
totalpage = problemList.size()/10+1;
}
//如果当前页面为尾页,总页数不为1
if(index == totalpage && totalpage !=1){
for(int j = (index-1)*10;j<problemList.size();j++){
Problem ComJobInfo = (Problem)problemList.get(j);
listPage.add(ComJobInfo);
}
}
//如果总页数为1,当前页数为1
else if(totalpage == 1 && index == 1){
for(int k = 0;k<problemList.size();k++){
Problem ComJobInfo = (Problem)problemList.get(k);
listPage.add(ComJobInfo);
}
}
//如果总页数不为1,当前页数为1
else if(totalpage != 1 && index == 1){
for(int i=0;i< index*10;i++){
Problem ComJobInfo = (Problem)problemList.get(i);
listPage.add(ComJobInfo);
}
}
else{
for(int y = (index-1)*10;y < index*10;y++){
Problem ComJobInfo = (Problem)problemList.get(y);
listPage.add(ComJobInfo);
}
} |
|