in spring web, get parameter from URL

  Kiến thức lập trình

I have this URL.

http://localhost:9000/api/datos-generales?page=0&size=20&sort=id,asc&filter=7588

and I want to recover the value of the last parameter. “filter”.

this is the signature of the method in the backend.

   @GetMapping("")
    public ResponseEntity<List<DatosGeneralesDTO>> getAllDatosGenerales(
        @org.springdoc.core.annotations.ParameterObject Pageable pageable,
       // @RequestAttribute(name = "filter", required = false, value = "") String filter,
        @RequestParam(name = "filter", defaultValue = "", required = false) String filter
    ) {
//SOME CODE
    log.debug('FILTER:", filter);
}

I’ve tried with RequestAttribute, RequestParam even with RequestBody but none of them can get the value in the param.

what is the right way?

1

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT