public Employee employeeOf(@PathVariable("number") EmployeeNumber number) {
return service.employeeOf(number);
}
@GetMapping
public String show() {
return "employee-edit";
}
@PostMapping
public String modify(@Valid @ModelAttribute("employee") Employee employee,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) return show();
service.modify(employee);
return String.format(“redirect:/employees/%s", employee.number());
}
@InitBinder
void initBinder(WebDataBinder binder) {
binder.setAllowedFields("mailAddress", "name");
}
}