日期:2014-05-19 浏览次数:21015 次
request.setCharacterEncoding("GBK"); page p = new page(); int count = p.getCount(); int pagesize = 2; int totalpage = p.getTotalpage(count, pagesize); String currentpage = request.getParameter("pageindex"); //System.out.println(currentpage); if (currentpage == null) { currentpage = "1"; } int pageindex = Integer.parseInt(currentpage); if (pageindex < 1) { pageindex = 1; } else if (pageindex > totalpage) { pageindex = totalpage; } List<News> list = p.getnewslist(pageindex, pagesize); //request.setAttribute("newslist", list); for (News news : list) { %> <%=news.getTitle()%><br /> <% } %> 当前页数[<%=pageindex%>/<%=totalpage%>] <% if (pageindex > 1) { %> <a href="test.jsp?pageindex=1">首页</a> <a href="test.jsp?pageindex=" <%=pageindex - 1%>>上一页</a> <% } if (pageindex < totalpage) { %> <a href="test.jsp?pageindex=" <%=pageindex + 1%>>下一页</a> <a href="test.jsp?pageindex=" <%=totalpage%>>尾页</a> <% } %>