Main
<!-- Q1. νμκ°μ
κΈ°λ₯ λ§λ€κΈ° -->
<li><h5>νμκ°μ
</h5></li>
<form action="JoinService" method="post">
<li><input type="text" id="inputE" placeholder="Emailμ μ
λ ₯νμΈμ"
name="email"></li>
<li><input type="button" id="inputE" value="Emailμ¦λΆμ²΄ν¬"
onclick="checkE()"></li>
<li><span id="resultCheck"></span></li>
<li><input type="password" placeholder="PWλ₯Ό μ
λ ₯νμΈμ" name="pw"></li>
<li><input type="text" placeholder="μ νλ²νΈλ₯Ό μ
λ ₯νμΈμ" name="tel"></li>
<li><input type="text" placeholder="μ§μ£Όμλ₯Ό μ
λ ₯νμΈμ" name="address"></li>
<li><input type="submit" value="JoinUs" class="button fit"></li>
</form>
MemberDTO
package com.smhrd.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
@Getter
@NoArgsConstructor
@ToString
@RequiredArgsConstructor
@AllArgsConstructor
public class Member {
@NonNull
private String email;
@NonNull
private String pw;
private String tel;
private String address;
}
MemberDAO
public int joinMember(Member vo) {
int cnt = 0;
try {
cnt = sqlSession.insert("com.smhrd.database.MemberMapper.joinMember", vo);
}catch(Exception e){
e.printStackTrace();
}finally {
sqlSession.close();
}
return cnt;
MemberMapper.xml
<mapper namespace="com.smhrd.database.MemberMapper">
<insert id = "joinMember" parameterType = "Member">
insert into WEB_MEMBER values(#{email},#{pw},#{tel},#{address}
</insert>
JoinService
System.out.println("[JoinService]");
//Postλ°©μ μΈγ
λ©
request.setCharacterEncoding("UTF-8");
//μμ²λ°μ΄ν°
String email = request.getParameter("email");
String pw = request.getParameter("pw");
String tel = request.getParameter("tel");
String address = request.getParameter("address");
Member vo = new Member(email,pw,tel,address);
System.out.println(vo.toString());
int cnt = new MemberDAO().joinMember(vo);
System.out.println("cnt : "+cnt);
if (cnt >0) {
System.out.println("Join success");
RequestDispatcher rd = request.getRequestDispatcher("JoinSuccess.jsp");
request.setAttribute("email", email);
rd.forward(request, response);
//response.sendRedirect("JoinSuccess.jsp?email="+email);
}else {
System.out.println("Join fail");
response.sendRedirect("Main.jsp");
}
}
Join Success
<div id="wrapper">
<!-- Menu -->
<nav id="Update">
<ul class="actions vertical">
<li><h1>νμν©λλ€!</h1></li>
<li>νμκ°μ
μ μΆνν©λλ€.</li>
<!-- Q2. νμκ°μ
ν νμμ 보 μ€ μ΄λ©μΌμ μΆλ ₯νμμ€.(requestμμ νμ©) -->
<li>λ©μΈμ§μμ€ν
μ μλ‘μ΄ μ΄λ©μΌμ ${email}μ
λλ€.</li>
<li>λ©μΈμ§μμ€ν
μ μλ‘μ΄ μ΄λ©μΌμ <%=email %>μ
λλ€.</li>
<li><button onclick='location.href="Main.jsp"'>μμνκΈ°</button></li>
</ul>
</nav>
</div>