SpringBoot数据分页工具类
/**
* 数据分页工具
*/
public class PageUtil {
public static Page pageHelp(@NotNull Integer pageNum, @NotNull Integer pageSize, @NotNull List<?> dataList){
pageNum = Math.abs(pageNum);
pageSize = Math.abs(pageSize);
Page page = new Page();
page.setPageNum(pageNum);
page.setPageSize(pageSize);
page.setTotal(dataList.size());
//剩余数据数
int surplus = dataList.size() % pageSize;
page.setDataList(dataList.subList(pageNum*pageSize>dataList.size()?dataList.size()-surplus:pageNum*pageSize-pageSize,pageNum*pageSize>dataList.size()?dataList.size():pageNum*pageSize));
return page;
}
}
标签:pageNum,SpringBoot,pageSize,dataList,NotNull,工具,size,page,分页
From: https://www.cnblogs.com/striver20/p/17095810.html