自定义jpa的pageImple替换类
@Data public class MyPage<T> implements Iterable<T>, Serializable { private static final long serialVersionUID = -3720998571176536865L; private List<T> content = new ArrayList<>(); private long totalElements; private int number; private int pageSize; private boolean first; private boolean last; private boolean empty; private int totalPages; private int numberOfElements; public MyPage() { } //只用把原来的page类放进来即可 public MyPage(Page<T> page) { this.content = page.getContent(); this.totalElements = page.getTotalElements(); this.number = page.getPageable().getPageNumber(); this.pageSize = page.getPageable().getPageSize(); this.first = page.isFirst(); this.last = page.isLast(); this.empty = page.isEmpty(); this.totalPages = page.getTotalPages(); this.numberOfElements = page.getNumberOfElements(); } //迭代器 @Override public Iterator<T> iterator() { return getContent().iterator(); } }