I just have a little problem where i can't figure out how to set one-indexed pagination. I'm using a rest-Api (extending jpaRepository)

I already tried some suggestion on the web (including stackoverflow ones) but it doesn't work for me, I tried a config file using "WebMvcConfigurerAdapter" but it's deprecated so i didn't go further. Isn't there a simple property i can append to my properties file to activate one-indexed pagination ? I also tried setting this property (spring.data.web.pageable.one-indexed-parameters=true) but it doesn't affect my application at all...

I want to use a GET request returning 10 items, but with one-indexed pagination

    public Page<Station> findAll(@RequestParam() int page,Pageable pageable) {
        return stationRepository.findAll(PageRequest.of(page, 10));
        //return stationRepository.findAll(pageable);
    }

This requests still shows me 0-indexed items and index-1 is the second page...etc. I expect it to be 1-indexed (page 1 should return the first items on my database)

EDIT: The pagination issue can be solved by setting the request page number to (page-1) from the server side :

    public Page<Station> findAll(@RequestParam() int page,Pageable pageable) {
        return stationRepository.findAll(PageRequest.of(page-1, 10));
        //return stationRepository.findAll(pageable);
    }

But the initial problem (setting one-indexed server pagination) still persists

0 Answers