1

I gets an error in Spring Boot , It say that I don't send paramSelect but it is false, I send paramSelect.

I send

 public filterResult(paramSelect: string, filterDateStart: string, filterDateEnd: string): Observable<any> {
  filterDateStart = filterDateStart.replace(/\//g, '-');
  filterDateEnd = filterDateEnd.replace(/\//g, '-');

const url = 'http://localhost:8080/filterResult/' + paramSelect + '/' + filterDateStart + '/' + filterDateEnd;
return this.http.get<any>(url);

Html ERROR->

zone.js:2969 GET http://localhost:8080/filterResult/EDU/04-07-2018/05-07-2018 400 ()

In my SpringBoot ->

@RequestMapping(method = RequestMethod.GET, value = "/filterResult/{paramSelect}/{dateStart}/{dateEnd}", produces = MediaType.APPLICATION_JSON_VALUE)
public List filterResult(@RequestParam("paramSelect") String  paramSelect , @RequestParam("dateStart") String dateStart , @RequestParam("dateEnd") String dateEnd) {
    System.out.println("llego");
    List<Parameter> list = pgService.filterResult(paramSelect, dateStart, dateEnd);
    return list;
}

I get an error:

Resolved exception caused by Handler execution: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'paramSelect' is not present
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
EduBw
  • 866
  • 5
  • 20
  • 40
  • Possible duplicate of [@RequestParam vs @PathVariable](https://stackoverflow.com/questions/13715811/requestparam-vs-pathvariable) – Jens Jul 30 '18 at 06:45

1 Answers1

3

You should change to use @PathVariable instead of @RequestParam for path variables:

 public List filterResult(@PathVariable("paramSelect") String  paramSelect , @PathVariable("dateStart") String dateStart , @PathVariable("dateEnd") String dateEnd) {
Ori Marko
  • 56,308
  • 23
  • 131
  • 233