1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

PageRequest in Spring Boot undefined

Discussão em 'Angular' iniciado por Hamza Sghaier, Outubro 5, 2024.

  1. I'm trying to implement pagination controller in my Springboot application, but I got this error:


    The constructor PageRequest(int, int) is undefined) (problem #1)
    ​

    I add an argument to match pagerequest (int, int, sort) to fix the problem, but the sort class is protected, so it says that the constructor PageRequest(int, int, Sort) is not visible (problem #2)

    Problem #1:

    @GetMapping("/list")
    @ResponseBody
    public Page<Posts> Pagination(@RequestParam(defaultValue="0") int page) {

    return PostsRepository.findAll(new PageRequest(page,4));

    }


    Problem #2:

    @GetMapping("/list")
    @ResponseBody
    public Page<Posts> Pagination(@RequestParam(defaultValue="0") int page) {

    return PostsRepository.findAll(new PageRequest(page,4,null));

    }

    Continue reading...

Compartilhe esta Página