创建 list 转 pageable 方法:
public static <T> Page<T> listConvertToPage(List<T> list, Pageable pageable) { int start = pageable.getOffset(); int end = (start + pageable.getPageSize()) > list.size() ? list.size() : (start + pageable.getPageSize()); return new PageImpl<T>(list.subList(start, end), list.size(), pageable); }
使用时直接调用:
Page<BdcZdListEntity> page = listConvertToPage(list, pageable); return page;