/**
* 测试分页
*/
@Test
public void testPage() {
int bulkSize = 2;
List<Integer> dataList = new ArrayList<>();
for (int i = 1; i <= 10; i++) {
dataList.add(i);
}
int offset = 0;
int currentPage = 1;
int pageSize = dataList.size() % bulkSize + 1;
while (currentPage <= pageSize) {
offset = (currentPage - 1) * bulkSize;
int max = currentPage == pageSize ? dataList.size() - offset : bulkSize;
for (; offset < max; offset++) {
System.out.println(dataList.get(offset));
}
currentPage++;
}
}