[DATACMNS-1309] Let work Pageable without query parameters Created: 02/May/18  Updated: 08/May/18  Resolved: 08/May/18

Status: Resolved
Project: Spring Data Commons
Component/s: Core
Affects Version/s: 2.0.6 (Kay SR6)
Fix Version/s: None

Type: Improvement Priority: Trivial
Reporter: Manuel Jordan Assignee: Oliver Drotbohm
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Last updater: Manuel Jordan


About the use of the PagingAndSortingRepository interface and the following configuration:

public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
	PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
        resolver.setFallbackPageable(PageRequest.of(0, 10));

I am able to work in a @Controller with the following:

@GetMapping(path="/complete", produces=MediaType.TEXT_HTML_VALUE)
public String findAllComplete(Pageable pageable, Model model){
    Page<Persona> personasPage = personaService.findAll(pageable);
    model.addAttribute("personasPage", personasPage);
    return "persona/findAllComplete";

Thus through the following URL

I am able to change the page and size in peace through the query parameters. It thanks to the PageableHandlerMethodArgumentResolver class support too.

Just wondered why is not possible work around this way (URI path variables)


Sadly for both cases appears the HTTP Status 404 – Not Found

I know is not critical, but I think is more elegant to work without query parameters.

Even if it is through a Web Browser interaction through a html page, in the 5. Paging and Sorting section of the Spring Data REST project, is possible observe that for Rest works with query parameters. To be honest I thought that for rest and uri was only possible work around path variables.

Comment by Oliver Drotbohm [ 08/May/18 ]

That'd require a completely different implementation of the resolver which you can of course write yourself but we won't. Generally speaking, path segments are much more invasive to the URI space we'd force on the users as they make up new resources. Pagination is basically limiting the output of a particular resource, which makes request parameters be the more natural choice.

Comment by Manuel Jordan [ 08/May/18 ]

Yes, I did a research. Is valid for Rest has these parameters (page, size and sort) because they represent 'filters' and they are not part of the Resource being retrieved.

Generated at Sat Jul 11 05:25:37 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.