diff --git a/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java b/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java index ec6076c..5356344 100644 --- a/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java +++ b/panda-code/src/main/java/org/panda/code/uitl/CollectionUtil.java @@ -63,25 +63,31 @@ public class CollectionUtil { public static List subPageList(List list,int page,int pageSize){ List pageList = new ArrayList(pageSize); //list不为NULL而且list的size>0 - if (list!=null&&list.size()>0&&page>0&&pageSize>0) { - //总页数 - int count = list.size(); - int pageCount = count / pageSize; - if ((pageCount % pageSize) != 0) { - pageCount++; - } - if (page <= pageCount) { - //开始索引 - int startIndex; - //结束索引 - int endIndex; - endIndex = (page * pageSize) - 1; - startIndex = endIndex - pageSize; - pageList = pageList.subList(startIndex, endIndex); + if (list!=null) { + if (list.size()>0&&page>0&&pageSize>0) { + //总页数 + int count = list.size(); + int pageCount = count / pageSize; + if ((pageCount % pageSize) != 0) { + pageCount++; + } + if (page <= pageCount) { + //开始索引 + int startIndex; + //结束索引 + int endIndex; + endIndex = (page * pageSize); + startIndex = endIndex - pageSize; + if (startIndex < 0) { + startIndex = 0; + } + pageList = list.subList(startIndex, endIndex); + } + }else { + pageList.addAll(list); } } return pageList; } - }