@PostMapping("members/new")
public String create(@Valid MemberForm form, BindingResult result) {
if(result.hasErrors()) {
return "members/createMemberForm";
}
Address address = new Address(form.getCity(), form.getCity(), form.getZipcode());
Member member = new Member();
member.setName(form.getName());
member.setAddress(address);
memberService.join(member);
return "redirect:/";
}
@Valid 뒤에 BindingResult를 사용하면 오류가 BindingResult에 담겨서 그 이후 코드가 실행된다.