I have some Sprint controller Mapping like below.
@GetMapping("/hello/{name}/age")
private String hello(@PathVariable(value = "name", required = true) String name){
//...
}
@GetMapping("/hello/{name}")
private String hello(@PathVariable(value = "name", required = true) String name){
//...
}
@GetMapping("/name")
private ResponseEntity<?> queryPerson(@RequestParam(value = "query", required = false) String query) {
// ...
}
But there is a client expetection to handle the below case
when client sends /hello/john/age, I should return age related pojo but when client calls /hello//age I have to return 400 with invalid user name as error.
Since im my code I already have other mapping hello/{name} so it is calling this API and trying to find username='age' and returing 404.
Here I am suppossed to 400 when user calls /hello//age, so how to handle this in spring?