by BehindJava
How to resolve MissingServelException in SpringBoot
In this tutorial we are to understand about MissingServeltException in Spring Boot.
In the SpringBoot application controller class we have the below mentioned method.
@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;
}
When we start our Spring boot application and invoke this method from the controller we get the below error.
Resolved exception caused by Handler execution: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'paramSelect' is not present
To resolve the above error we need to to change @PathVariable instead of @RequestParam for path variables:
public List filterResult(@PathVariable("paramSelect") String paramSelect , @PathVariable("dateStart") String dateStart , @PathVariable("dateEnd") String dateEnd)