I want to restrict the list of allowed request parameters in my controller, so that if I get a request with an undefined parameter in the controller, it should return a bad request, but it returns 200 OK.
I think that this one should be fixed on the framework level, but not in the controller layer. I am confused about it, and could not find anything on the internet
For e.g I have the following controller definition:
@GetMapping("/Client") public ResponseEntity<List<Client>> getAllClients(HttpServletRequest httpServletRequest, @RequestParam(value = McsConstants.PAGE_HEADER, required = false) Integer page, @RequestParam(value = McsConstants.SIZE_HEADER, required = false) Integer size) {...} And the valid request would be
GET .../Client GET .../Client?page=1 GET .../Client?size=10 GET .../Client?page=1&size=10 How can I validate the case when I have an undefined request param like below?
GET .../Client?someUndefinedParam=1 Let me know please for any ideas or links
Thanks!