JSP_Maven_Member(-Join-)πŸ‘Ό

화이티 Β·2023λ…„ 12μ›” 19일
0

JSP

λͺ©λ‘ 보기
1/12

Join member

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>
profile
μ—΄μ‹¬νžˆ κ³΅λΆ€ν•©μ‹œλ‹€! The best is yet to come! πŸ’œ

0개의 λŒ“κΈ€