Hello

회원가입 시작하기

by 볼빵빵오춘기

MemberController

@Controller
@RequestMapping("/member")
public class MemberController {
    @GetMapping("/save")
    public String saveForm(){
        return "save";
    }
}

 

save.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>회원가입</title>
</head>
<body>
    <form action="/member/save" method="post">
        <input type="text" name="memberEmail" placeholder="이메일"><br>
        <input type="text" name="memberPassword" placeholder="비밀번호"><br>
        <input type="text" name="memberName" placeholder="이름"><br>
        <input type="text" name="memberAge" placeholder="나이"><br>
        <input type="text" name="memberMobile" placeholder="전화번호"><br>
        <input type="submit" value="회원가입">
    </form>
</body>
</html>

 

MemberController

@PostMapping("/save")
public String save(){ // @RequestParam 을 이용할 수 있지만 DTO로 받아오기
    return "";
}

 

MemberDTO

@Getter
@Setter
@ToString
public class MemberDTO {
    private Long id;
    private String memberEmail;
    private String memberPassword;
    private String memberName;
    private int memberAge;
    private String memberMobile;
}

 

MemberController

@PostMapping("/save")
public String save(@ModelAttribute MemberDTO memberDTO){ // @RequestParam 을 이용할 수 있지만 DTO로 받아오기
    System.out.println(memberDTO);
    memberService.save(memberDTO);
    return "";
}

 

 

블로그의 정보

Hello 춘기's world

볼빵빵오춘기

활동하기