I am using spring boot with hibernate and I want to use pagination in my project. I have searched on google and saw many examples but I am unable to implement it in my proje
Check it. Your controller
@RequestMapping("/top/pages/{pageno}")
@ResponseBody
public List getAllPosts(@PathVariable("pageno") int pageno, HttpServletRequest req, HttpServletResponse res) throws ServletException {
List postobj = postDao.getAllPostsByRank(new PageRequest(pageno,10));
return postobj;
}
Your dao
@Transactional
public interface PostDao extends CrudRepository{
@Query(getAllPostsByRank)
List getAllPostsByRank(Pageable pageable);
final String getAllPostsByRank= "from Post order by value DESC";
}