0.처음으로 Vo 페이지 만들기
멤버 변수를 지정해준다음에 setter , getter 만들어주세요
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
public class MemberVo {
private int member_idx;
private String member_id;
private String member_name;
private String member_pw;
private String member_phone;
private Date member_regdate;
private int member_grade;
private String member_delyn;
private Date member_deldate;
public int getMember_idx() {
return member_idx;
}
public void setMember_idx(int member_idx) {
this.member_idx = member_idx;
}
public String getMember_id() {
return member_id;
}
public void setMember_id(String member_id) {
this.member_id = member_id;
}
public String getMember_name() {
return member_name;
}
public void setMember_name(String member_name) {
this.member_name = member_name;
}
public String getMember_pw() {
return member_pw;
}
public void setMember_pw(String member_pw) {
this.member_pw = member_pw;
}
public String getMember_phone() {
return member_phone;
}
public void setMember_phone(String member_phone) {
this.member_phone = member_phone;
}
public Date getMember_regdate() {
return member_regdate;
}
public void setMember_regdate(Date member_regdate) {
this.member_regdate = member_regdate;
}
public int getMember_grade() {
return member_grade;
}
public void setMember_grade(int member_grade) {
this.member_grade = member_grade;
}
public String getMember_delyn() {
return member_delyn;
}
public void setMember_delyn(String member_delyn) {
this.member_delyn = member_delyn;
}
public Date getMember_deldate() {
return member_deldate;
}
public void setMember_deldate(Date member_deldate) {
this.member_deldate = member_deldate;
}
|
cs |
1. JSP 페이지 구현하기 ( 간단한 FORM 객체 )
1
2
3
4
5
6
7
8
9
10
11
12
|
<form name="joinForm" action="/spring/joinProcess.do" method="post">
<input type="email" name="member_id" id="member_id" value="" maxlength="80" placeholder="아이디(이메일)" /><br/>
<input type="button" id="checkId" value="중복검사"><br/>
<div><span id="result_checkId" style="font-size:12px;"></span></div>
<input type="password" name="member_pw" value="" maxlength="20" placeholder="비밀번호"><p/>
<input type="text" name="member_name" maxlength="40" value="" placeholder="이름"><p/>
<input type="tel" name="member_phone" value="" autocomplete="off" placeholder="휴대폰 번호"><p/>
<input type="submit" value="가입하기">
<input type="reset" value="취소하기">
</form>
|
cs |
저는 /Spring/joinprocess.do 로 보내보겠습니다.
2. Controller [ JSP 페이지 >> Controller ( form action mapping 이동 )
1
2
3
4
5
6
7
8
9
10
11
12
13
|
@PostMapping("/joinProcess.do")
public String joinProcess(MemberVo memberVo) {
//form 에서 전송된 VO 값이 memberVo 에저장
int result=memberService.join(memberVo);
//int 로 받는 이유는 DB 에서 정상적으로 //회원가입이 되면 "1"행이 실행된거 알기위해서에요 String viewPage = null;
if(result==1) { // DB 저장 성공시실행
viewPage = "redirect:/home.do";
}else{ // DB저장 실패시 실행
viewPage = "member/join";
}
return viewPage;
}
|
cs |
만들어준 MemberVO memberVo 값에 JSP 에서 name 값이 자동으로 저장되어서
int result = memberService.join(memberVo); join 멤버 값을 넣어줍니다.
3. Controller 에서 Service page 로 memberVo 값이동
1
2
3
4
5
6
|
public int join(MemberVo memberVo) {
int result=0;//변수 0 으로 초기화선언
result = memberDao.joinMember(memberVo);
return result;
}
|
cs |
4.Service 에서 Dao page 로 memberVo 값이동
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
@Repository
public class MemberDao {
private SqlSession sqlSession;
public static final String MAPPER = "ezen.dev.spring.member";
@Autowired
public MemberDao(SqlSession sqlSession) {
this.sqlSession = sqlSession;
}
public int joinMember(MemberVo memberVo) {
return sqlSession.insert(MAPPER+".joinMember", memberVo);
}
|
cs |
5.Dao 에서 mapper 로 sql문 실행 ( mysql 기준)
1
2
3
4
5
6
|
<mapper namespace = "ezen.dev.spring.member">
<insert id="joinMember" parameterType="memberVo">
insert into member(member_id, member_pw, member_name, member_phone)
values(#{member_id}, #{member_pw}, #{member_name}, #{member_phone})
</insert>
|
cs |
memberVO 값을 받아서 DB 실행을 시켜 결과 값이 나오면 됨
6.정상적으로 회원가입 완료 !!!
감사합니다~
'기존 > 🏀Spring' 카테고리의 다른 글
[스프링 -3]Spring 중복확인 Ajax요청 (아이디 중복확인) (0) | 2022.07.14 |
---|---|
[스프링 -2]Spring 로그인하기 (DB저장,mapper,mybatis) (0) | 2022.07.14 |
[스프링]Spring 카카오 로그인하기 , DB저장 (0) | 2022.07.14 |
(스프링) 일반배송 만들기 주문상태현황,배송중,배송대기,결제완료 (0) | 2022.07.11 |
(스프링) 일반배송 만들기 주문상태현황,배송중,배송대기,결제완료 (0) | 2022.07.11 |