/** * 分页 * * @param totalPage * @param pageSize */ public static void forPage(int totalPage, int pageSize) { HttpServletRequest request = ServletUtil.getRequest(); request.setAttribute("url", generateUrl()); request.setAttribute("curPage", getCurPage()); request.setAttribute("totalPage", validateTotalPage(totalPage)); }
public static String generateUrl(Map<String, Object> map) { StringBuffer url = ServletUtil.getRequest().getRequestURL(); Iterator<String> iterator = map.keySet().iterator(); url.append("?"); while (iterator.hasNext()) { String key = iterator.next(); String value = String.valueOf(map.get(key)); url.append(key + "="); url.append(value + "&"); } url.append("curPage={curPage}"); return url.toString(); }
public static void forPage(int totalPage, int pageSize, Map<String, Object> conditionMap) { HttpServletRequest request = ServletUtil.getRequest(); request.setAttribute("url", generateUrl(conditionMap)); request.setAttribute("curPage", getCurPage()); request.setAttribute("totalPage", validateTotalPage(totalPage)); }
public static int getPageSize() { return ServletRequestUtils.getIntParameter(ServletUtil.getRequest(), "pageSize", 10); }
public static int getCurPage() { int curPage = ServletRequestUtils.getIntParameter(ServletUtil.getRequest(), "curPage", 1); if (curPage < 1) curPage = 1; return curPage; }
public static String generateUrl() { StringBuffer url = ServletUtil.getRequest().getRequestURL(); url.append("?curPage={curPage}"); return url.toString(); }