Skip to content

Commit

Permalink
上次修改出现bug修复
Browse files Browse the repository at this point in the history
修复跳转一直跳到第一页的问题
  • Loading branch information
fujiangfer committed Mar 30, 2021
1 parent 476becc commit fc6762a
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ public void service(HttpServletRequest req, HttpServletResponse resp) throws Ser
int maxPage = 0;// 最大页
int pageCount = posts.size();// 得到查询出来的所有数据的数目
// 如果是第一次执行,就会接收不到数据
if ((strNum == null)||(strNum.equals(""))) {
strNum = "0";
} else {// 接收到了用户点击的第几(pageNum)页
pageNum = Integer.parseInt(strNum);
if (pageNum < 0 || pageNum > maxPage)pageNum = 0;
}
// 计算出要分多少页
if (pageCount % 31 == 0) {
maxPage = pageCount / 31;
} else {
maxPage = pageCount / 31 + 1;
}
if ((strNum == null)||(strNum.equals(""))) {
strNum = "0";
} else {// 接收到了用户点击的第几(pageNum)页
pageNum = Integer.parseInt(strNum);
if (pageNum < 0 || pageNum > maxPage)pageNum = 0;
}

req.setAttribute("maxPage", maxPage);// 存储最大页数
req.setAttribute("pageNum", pageNum);// 将当前页面存储起来,给分页页面使用
req.setAttribute("posts", posts);
Expand Down

0 comments on commit fc6762a

Please sign in to comment.