So I have in my controller a GET method with optional request params:
@GetMapping(path = "/users/search")
public @ResponseBody ResponseEntity<List<User>> getUserLike(
@RequestParam(name = "id", required = false) Long id,
@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "dateofbirth", required = false) @DateTimeFormat(pattern = "dd-MM-yyyy") LocalDate dateOfBirth
) {
return userService.getUserLike(id, name, dateOfBirth);
}
When I try to call this request with unknown parameters
/users/search?id=1&myunknownparam=unknownParam
I'd like to raise an Exception when request has unknown param such as myunknownparam here.
Though for now as all my parameters are optional my service returns the same result as it would with all the parameters set to null.