import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import java.util.List;
public class ListToPageUtil {
public static <T> PageInfo<T> toPage(Integer pageNum, Integer pageSize, List sourceList, T t){
Page page = new Page(pageNum, pageSize);
int total = sourceList.size();
page.setTotal(total);
int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min((startIndex + pageSize), total);
page.addAll(sourceList.subList(startIndex, endIndex));
PageInfo<T> pageInfo = new PageInfo(page);
return pageInfo;
}
}
java 将list分页
最新推荐文章于 2024-04-26 16:27:05 发布