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; } }