|
|
|
@ -63,25 +63,31 @@ public class CollectionUtil { |
|
|
|
|
public static <T> List<T> subPageList(List<T> list,int page,int pageSize){ |
|
|
|
|
List<T> 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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|