Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
Use múltiples parámetros paginables en el punto final de Spring MVC

yo tengo una situacion asi

 @Autowired private CustomerRepository repo; @RequestMapping("/") public Page<Customer> getDocuments(@Qualifier("bar") Pageable pageable, @Qualifier("foo")Pageable pageable2) { return repo.findAll(pageable,pageable2.getOffset(), pageable2.getPageSize()); }

pero no funcionó bien. Mi pregunta es, ¿cómo puedo distinguir entre los valores de los parámetros?

Para lograr el escenario anterior, tuve que cambiar mi método a este:

 @RequestMapping("/") public Page<Customer> getDocuments(Pageable pageable, @RequestParam(value="from", defaultValue="0") int offSet, @RequestParam(value="length", defaultValue="3") int length) { return repo.findAll(pageable, offSet, length); }
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Finalmente, he encontrado mi respuesta. Lo que hice fue absolutamente correcto, pero estaba pasando los parámetros incorrectos en mi URL.

En resumen, si está pasando dos Pageable, tiene que haber un @Qualifier y debe configurar su parámetro de solicitud en consecuencia.

lo que estaba pasando antes en la URL http://localhost:8080/?page=0&size=2&page=0&size=3 y la URL correcta sería http://localhost:8080/?bar_page=0&bar_size=2&foo_page=0&foo_size=3

PD: quien haya votado negativamente mi pregunta, todavía estoy enojado con él / ellos.

about 4 years ago · Santiago Trujillo Report

0

Creo que es una idea incorrecta pasar los frijoles Spring como argumento para descansar el recurso. Si es necesario acceder a los valores desde Bean, debe accederse dentro del recurso suponiendo que Bean ya esté inicializado.

`@Autowired repositorio privado de CustomerRepository;

 @Autowired @Qualifier("bar") Pageable pageable; @Autowired @Qualifier("foo") Pageable pageable2; @RequestMapping("/") public Page<Customer> getDocuments(){ return repo.findAll(pageable,pageable2.getOffset(),pageable2.getPageSize()); }`
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!