我正在使用带有hibernate的spring boot,我想在我的项目中使用分页.我在谷歌上搜索并看到很多例子,但我无法在我的项目中实现它.
我想如果我在我的网址中传递1然后10个结果应该来,如果我传递2然后接下来10个结果应该来,依此类推.
这是我的道
@Transactional
public interface PostDao extends CrudRepository<Post, Long>{
@Query(getAllPostsByRank)
List<Post> getAllPostsByRank();
final String getAllPostsByRank= "from Post order by value DESC";
}
Run Code Online (Sandbox Code Playgroud)
这是我的控制器
@RequestMapping("/top")
@ResponseBody
public List<Post> getAllPosts(HttpServletRequest req, HttpServletResponse res) throws ServletException {
List<Post> postobj = postDao.getAllPostsByRank();
return postobj;
}
Run Code Online (Sandbox Code Playgroud)
这是我的网址:
http://localhost:8888/v1.0/post/top/1
Run Code Online (Sandbox Code Playgroud)
请建议.