mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
ListUtil的page方法
调用PageUtil.setFirstPageNo(),如果firstPageNo不是从0开始计算会发生错误
This commit is contained in:
parent
c4a91615b4
commit
5208e5b02d
@ -245,7 +245,7 @@ public class ListUtil {
|
||||
int resultSize = list.size();
|
||||
// 每页条目数大于总数直接返回所有
|
||||
if (resultSize <= pageSize) {
|
||||
if (pageNo < 1) {
|
||||
if (pageNo < (PageUtil.getFirstPageNo()+1)) {
|
||||
return Collections.unmodifiableList(list);
|
||||
} else {
|
||||
// 越界直接返回空
|
||||
|
@ -97,5 +97,10 @@ public class ListUtilTest {
|
||||
Assert.assertArrayEquals(new int[]{3,4},c2);
|
||||
Assert.assertArrayEquals(new int[]{5},c3);
|
||||
Assert.assertArrayEquals(new int[]{},c4);
|
||||
|
||||
|
||||
PageUtil.setFirstPageNo(1);
|
||||
int[] d1 = ListUtil.page(0,8,a).stream().mapToInt(Integer::valueOf).toArray();
|
||||
Assert.assertArrayEquals(new int[]{1,2,3,4,5},d1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user