zoukankan      html  css  js  c++  java
  • list集合进行分页

    /**
         * list集合分页
         *
         * @param list        分页数据
         * @param pagesize    页面大小
         * @param currentPage 当前页面
         */
        @SuppressWarnings("unchecked")
        public static Map<String, Object> pageBySubList(List list,  int currentPage ,int pagesize) {
            Map<String, Object> map = new HashMap<>();
            if (!isEmpty(list)) {
                int totalcount = list.size();
                int pagecount = 0;
                List<String> subList;
                int m = totalcount % pagesize;
                if (m > 0) {
                    pagecount = totalcount / pagesize + 1;
                } else {
                    pagecount = totalcount / pagesize;
                }
                if (m == 0) {
                    subList = list.subList((currentPage - 1) * pagesize, pagesize * (currentPage));
                } else {
                    if (currentPage == pagecount) {
                        subList = list.subList((currentPage - 1) * pagesize, totalcount);
                    } else {
                        subList = list.subList((currentPage - 1) * pagesize, pagesize * (currentPage));
                    }
                }
                map.put("list", subList);
                map.put("pages", pagecount);
                map.put("total", totalcount);
            } else {
                map.put("list", new ArrayList<>());
                map.put("pages", 1);
                map.put("total", 0);
            }
            return map;
        }
  • 相关阅读:
    如何在Ubuntu上安装Wine 2.6
    51nod 1012 最小公倍数LCM
    二次urldecode注入
    CTF中的变量覆盖问题
    redis的bind误区
    宽字节注入原理
    PHP靶场-bWAPP环境搭建
    xxe-lab学习
    PHP代码审计之create_function()函数
    SSRF打认证的redis
  • 原文地址:https://www.cnblogs.com/yeg0zj/p/15176026.html
Copyright © 2011-2022 走看看