日期:2014-05-20 浏览次数:20616 次
int curPage=Integer.parseInt(request.getParameter("curPage")==null?"1":request.getParameter("curPage"));//当前页 int perPage=5;//每页个数 int totalPage;//总页数 if(list.size()%perPage==0){ totalPage=list.size()/perPage; }else{ totalPage=list.size()/perPage+1; } if(curPage<1){ curPage=1; } if(curPage>totalPage){ curPage=totalPage; } if(curPage<1){ curPage=1; } int startIndex=(curPage-1)*perPage; int endIndex=startIndex+perPage; if(endIndex>list.size()){ endIndex=list.size(); } request.setAttribute("curPage", curPage); request.setAttribute("totalPage", totalPage); list=list.subList(startIndex, endIndex);