how can I make @getmapping without id and by (String) name .....
@GetMapping("/employees/{id}")
Employee one(@PathVariable Long id) {
return repository.findById(id)
.orElseThrow(() -> new EmployeeNotFoundException(id));
}
You can do it the same way you already are but switch out id with name
@GetMapping("/employees/{name}")
Employee one(@PathVariable String name) {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.