Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1309

Let work Pageable without query parameters

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.6 (Kay SR6)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

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

      @Override
      public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
      	PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
              resolver.setOneIndexedParameters(true);
              resolver.setFallbackPageable(PageRequest.of(0, 10));
              resolvers.add(resolver);
      	WebMvcConfigurer.super.addArgumentResolvers(resolvers);
      }
      

      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)

      or

      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.

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              dr_pompeii Manuel Jordan
              Last updater:
              Manuel Jordan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: