先说说获取到最终代码的思路
先来看看实现JPA接口的关于分页的方法
接下来去看看Pageable接口如何实现
在csdn上搜索并浏览几个博客会知道,实现Pageable接口要用PageRequest类实现
然后我们就可以使用JPA中的方法将值赋给Page的引用了
@Autowired
BookRepository bookRepository
Page<Book> page = bookRepository.findAll(pageable);
//BookRepository是实现实体类的接口
最后我们利用IDEA的 . 提示来确定有哪些方法是我们想要的
显然,第一个就是我们想要的,输出书籍信息