이전시간, MemberController도 만들고 의존관계도 설정해놓음
이제 이 MemberController를 통해 회원을 등록하고 조회하는 걸 만들어보자!
MemberController.java
@Controller
public class MemberController {
private MemberService memberService;
@Autowired
public MemberController(MemberService memberService){
this.memberService = memberService;
}
@GetMapping("/members/new")
public String createForm(){
return "members/createMemberForm";
}
@PostMapping("/members/new")
public String create(MemberForm form){
Member member = new Member();
member.setName(form.getName());
memberService.join(member);
return "redirect:/";
}
}