当设置日期输入(required = false)但使用错误的正则表达式(fe 10-2019)时,我希望我的 RestController 返回错误
@GetMapping
@Timed
public ResponseEntity<ResponseBodyWrapper<List<ListData>>> getList(
@RequestParam(name = "date", required = false) @Pattern(regexp = "[0-9]{4}-[0-9]{1,2}") String date) {
// Logic
}
Run Code Online (Sandbox Code Playgroud)
但是,验证并未进行。我期待一个错误,但没有抛出任何错误,当我尝试使用错误的输入构建一个新对象时,错误发生了