package cn.com.oims.common; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * list的分页查询以及和Map之间的转换,当前页,每页显示条数,总页数。 * @author GuoBaoqiang * */ public class getListForPage { /** * 分页方法 * * @param list * 源数据 * @param currentPage * 当前页 * @param maxNum * 每页显示几条 * @param pageNum * 总页数 * @return */ public static List getPageList(List list, int currentPage, int maxNum, int pageNum) { int fromIndex = 0; // 从哪里开始截取 int toIndex = 0; // 截取几个 if (list == null || list.size() == 0) return null; // 当前页小于或等于总页数时执行 if (currentPage <= pageNum && currentPage != 0) { fromIndex = (currentPage - 1) * maxNum; if (currentPage == pageNum) { toIndex = list.size(); } else { toIndex = currentPage * maxNum; } } return list.subList(fromIndex, toIndex); } /** * 和list之间的转化 * */ public static boolean checkList(Map map,List list){ boolean flag=false; List l=new ArrayList(); Set set=map.keySet(); Iterator iterator=set.iterator(); while(iterator.hasNext()){ l.add(map.get(iterator)); } for (int i = 0; i < l.size(); i++) { if(l.get(i).equals(list.get(i))){ flag=true; } else flag=false; } return flag; } }


微信网友_6802139027345408 LV2
2023年12月31日
lironggang LV38
2023年3月26日
heqian LV17
2023年1月10日
qwdqwdqw LV3
2022年12月2日
tangjj7260 LV18
2021年12月8日
.空运绵熊. LV1
2021年6月5日
Diontll LV3
2020年11月23日
yale1422688399 LV3
2020年11月16日
kerry0304 LV4
2020年5月9日
能不能不存在 LV13
2020年4月30日