Here is my Get request:
@GetMapping("/stats/{fromDate}/{toDate}")
public StatsSummary getStatsSummary(@PathVariable String fromDate, @PathVariable String toDate) {
logger.info("Calculating statistics between" + fromDate + ",to" + toDate);
return statsService.getStatsSummary(fromDate, toDate);
}
I've tried adding the annotation @NotBlank as:
public StatsSummary getStatsSummary(@PathVariable String fromDate, @PathVariable @NotBlank String toDate) {
but when I invoke /stats/2020-05-30/ which does not include toDate I receive the response:
{
"timestamp": "2020-09-04T06:02:46.567+00:00",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/stats/2020-05-30/"
}
So the annotation is not being registered correctly?
Update:
It seems PathVariable is not meant to be validated:
The validators (@Validated @Valid) do not work with Spring and TomEE