diff --git a/221801121&221801131/java/edu/fzu/postsearch/servlet/PostServlet.java b/221801121&221801131/java/edu/fzu/postsearch/servlet/PostServlet.java index 642f85d59..c3b46df10 100644 --- a/221801121&221801131/java/edu/fzu/postsearch/servlet/PostServlet.java +++ b/221801121&221801131/java/edu/fzu/postsearch/servlet/PostServlet.java @@ -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);