最好用的分页代码(java版)(2)
发布时间:2021-06-05
发布时间:2021-06-05
public void init(HttpServletRequest request, String sql, int pageSize, int groupSize, int pageNo, String url) { // 上一页、下一页跳转路径 if (url != null) { this.url = url; } else { this.url = request.getRequestURL() + ""; } if (pageSize > 0) this.pageSize = pageSize;// 每页多少条记录 if (groupSize > 0) this.groupSize = groupSize; // 当前第几页 if (pageNo < 0) { this.curPageNo = 0; } else { this.curPageNo = pageNo; } int curGroup = this.curPageNo / this.groupSize + 1; // 是否是新的一组数据,如果是则到数据库取数据 this.size = parseInt(request.getSession().getAttribute("page_all_size") + "", 0); if (this.curPageNo % this.groupSize == 0 || (request.getSession().getAttribute("cur_group") != null && parseInt( "" + request.getSession().getAttribute("cur_group"), 1) != curGroup) || this.size == 0 || request.getParameter("reload") != null) { request.getSession().setAttribute("cur_group", curGroup); if (pageNo > 0 && request.getSession().getAttribute("page_sql") != null) { sql = request.getSession().getAttribute("page_sql") + ""; } else { request.getSession().setAttribute("page_sql", sql); } this.size = getTotalCount(sql); List list = getPageData(sql, (this.curPageNo / this.groupSize) * this.pageSize * this.groupSize, this.pageSize * this.groupSize); request.getSession().setAttribute("page_all_size", this.size); request.getSession().setAttribute("page_cur_list", list); this.setShowList(list);// 设置页面上的显示数据 } else { this.setShowList((List) request.getSession().getAttribute( "page_cur_list"));// 设置页面上的显示数据 }
上一篇:四级完形精选练习及答案(26)
下一篇:桑黄胞外多糖药理活性的初步研究