1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] PageRequest in Spring Boot undefined

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 5, 2024 às 17:02.

  1. Stack

    Stack Membro Participativo

    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