Spring Controller: RequestParam not validated despite @Valid and @Size
问题 I have a simple Controller method : @GetMapping("/search") public List<Result> search(@RequestParam @Valid @NotNull @Size(min = 4) String query) { return searchService.search(query); } When I omit the "query" parameter, I get a 400 Bad Request, as expected. Testing the method with these query parameters doesn't work. All but the last test should return a "400 Bad Request". "/search" --> actual 400 Bad Request, test passes "/search?query=" --> actual 200 Ok, expected 400 because @Size(min=4) "