반응형
- root-context.xml
<!-- Mybatis 관련 빈 등록.... -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"></property>
<property name="username" value="learning"></property>
<property name="password" value="1234"></property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
</bean>
<mybatis-spring:scan base-package="com.yu.learning.*.mapper"/>
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<context:component-scan base-package="com.yu.learning.*.service"></context:component-scan>
- 웹사이트에 먼저 회원가입 양식을 만든다.
회원가입 시 필요한 정보
First Name
Last Name
Password
DROP TABLE MEMBER;
CREATE TABLE MEMBER(
member_no NUMBER PRIMARY KEY,
firstname VARCHAR2(200),
lastname VARCHAR2(200),
email VARCHAR2(200),
password VARCHAR2(200)
);
DROP SEQUENCE MEMBER_seq;
CREATE SEQUENCE MEMBER_seq;
- 회원가입 시 입력한 정보들이 데이터베이스에 입력되게 한다.
how?
아래 코드들의 해당 칸들에 모두 <input> 에 name 을 붙여준다.
<div class="row mt-5">
<div class="col-4" style="margin: auto; text-align: center;">First
Name</div>
<div class="col">
<input type="text" class="form-control">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Last
Name</div>
<div class="col">
<input type="text" class="form-control">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Email</div>
<div class="col">
<input type="text" class="form-control">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Password</div>
<div class="col">
<input type="password" class="form-control">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Confirmed
Password</div>
<div class="col">
<input type="password" class="form-control">
</div>
</div>
<div class="row mt-4">
<div class="col" style="font-weight: bold; text-align: center;">
<input type="checkbox"> I read and agree to Terms & Condition
</div>
</div>
<div class="row mt-3">
<div class="col"
style="font-weight: bold; text-align: center; font-size: 2em;">
<a href="${pageContext.request.contextPath}/member/sign_up_process.do">
<input type="button" class="btn btn-primary form-control"
value="Sign up">
</a>
</div>
</div>
회원가입 양식을 form 태그로 감싸준 후에
input 요소들에 다 name 태그를 붙여줬다.
<form
action="${pageContext.request.contextPath }/member/sign_up_process.do">
<div class="row mt-5">
<div class="col"></div>
<div class="col">
<div class="row mt-5">
<div class="col"
style="font-weight: bold; text-align: center; font-size: 1.8em;">
Create a Learn-Ing Account</div>
</div>
<div class="row mt-5">
<div class="col-4" style="margin: auto; text-align: center;">First
Name</div>
<div class="col">
<input type="text" class="form-control" name="firstname">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Last
Name</div>
<div class="col">
<input type="text" class="form-control" name="lastname">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Email</div>
<div class="col">
<input type="text" class="form-control" name="email">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Password</div>
<div class="col">
<input type="password" class="form-control" name="password">
</div>
</div>
<div class="row mt-4">
<div class="col-4" style="margin: auto; text-align: center;">Confirmed
Password</div>
<div class="col">
<input type="password" class="form-control">
</div>
</div>
<div class="row mt-4">
<div class="col" style="font-weight: bold; text-align: center;">
<input type="checkbox"> I read and agree to Terms &
Condition
</div>
</div>
<div class="row mt-3">
<div class="col"
style="font-weight: bold; text-align: center; font-size: 2em;">
<input type="submit" class="btn btn-primary form-control"
value="Sign up">
</div>
</div>
<div class="row mt-3">
<div class="col" style="text-align: center;">
Already have an account? <b style="color: blue;"> <a
style="text-decoration: none;"
href="${pageContext.request.contextPath }/member/sign_in.do">Sign
in</a>
</b>
</div>
</div>
</div>
<div class="col"></div>
</div>
</form>
MemberController에 입력하여 MemberServiceImple과 연결해준다.
-
@Autowired
private MemberServiceImpl memberService;
- MemberVo 생성
package com.yu.learning.vo;
import java.sql.Date;
public class Member {
private int member_no;
private String member_firstname;
private String member_lastname;
private String member_email;
private String member_pw;
private Date member_joindate;
public Member() {
super();
// TODO Auto-generated constructor stub
}
public Member(int member_no, String member_firstname, String member_lastname, String member_email, String member_pw,
Date member_joindate) {
super();
this.member_no = member_no;
this.member_firstname = member_firstname;
this.member_lastname = member_lastname;
this.member_email = member_email;
this.member_pw = member_pw;
this.member_joindate = member_joindate;
}
public int getMember_no() {
return member_no;
}
public void setMember_no(int member_no) {
this.member_no = member_no;
}
public String getMember_firstname() {
return member_firstname;
}
public void setMember_firstname(String member_firstname) {
this.member_firstname = member_firstname;
}
public String getMember_lastname() {
return member_lastname;
}
public void setMember_lastname(String member_lastname) {
this.member_lastname = member_lastname;
}
public String getMember_email() {
return member_email;
}
public void setMember_email(String member_email) {
this.member_email = member_email;
}
public String getMember_pw() {
return member_pw;
}
public void setMember_pw(String member_pw) {
this.member_pw = member_pw;
}
public Date getMember_joindate() {
return member_joindate;
}
public void setMember_joindate(Date member_joindate) {
this.member_joindate = member_joindate;
}
}
- MemberSQLMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yu.learning.member.mapper.MemberSQLMapper">
<insert id="insert">
<![CDATA[
INSERT INTO MEMBER VALUES(
MEMBER_SEQ.NEXTVAL, #{member_firstname}, #{member_lastname}, #{member_email}, #{member_pw}, SYSDATE
)
]]>
</insert>
</mapper>
반응형
'portfolio-projects > Learn-Ing' 카테고리의 다른 글
[Learn-Ing] 1. 메인페이지 완성 (0) | 2021.06.02 |
---|---|
[개인프로젝트] 1. 스프링 설정하기 (0) | 2021.05.30 |