이안의 평일코딩

Spring 16일차 - Transaction 게시판 만들기 / 쿠키 본문

Back-end/Spring

Spring 16일차 - Transaction 게시판 만들기 / 쿠키

이안92 2020. 11. 18. 12:09
반응형

2020.11.18(수)

SpringAOPProject3

기본설정 후

 

SQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
CREATE TABLE spring_reply(
    no NUMBER PRIMARY KEY,
    name VARCHAR2(34NOT NULL,
    subject VARCHAR2(1000NOT NULL,
    content CLOB NOT NULL,
    pwd VARCHAR2(10NOT NULL,
    regdate DATE DEFAULT SYSDATE,
    hit NUMBER DEFAULT 0,
    gi NUMBER, --답변
    gs NUMBER DEFAULT 0,
   gt NUMBER DEFAULT 0,
    root NUMBER DEFAULT 0,
    depth NUMBER DEFAULT 0
);
cs
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
CREATE TABLE board_count(
    name VARCHAR2(34NOT NULL,
    hit NUMBER
);
 
CREATE OR REPLACE TRIGGER board_trigger
AFTER INSERT ON spring_reply
FOR EACH ROW
DECLARE
    v_cnt NUMBER;
BEGIN
    SELECT COUNT(*INTO v_cnt
    FROM board_count
    WHERE name=:NEW.name;
    
    IF(v_cnt=0) THEN
        INSERT INTO board_count VALUES(:NEW.name,1);
    ELSE
        UPDATE board_count SET
        hit=hit+1
        WHERE name=:NEW.name;
    END IF;
END;
/
cs

*Trigger에서 commit; 쓰면 안된다!

 

 

WEB-INF/config

application-context.xml

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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    <context:component-scan base-package="com.sist.*"/>
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>text/html;charset=UTF-8</value>
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <bean id="ds" class="org.apache.commons.dbcp.BasicDataSource"
        p:driverClassName="oracle.jdbc.driver.OracleDriver"
        p:url="jdbc:oracle:thin:@localhost:1521:XE"
        p:username="hr"
        p:password="happy"
    />
    <aop:aspectj-autoproxy/>
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="ds"
    />
    <bean id="ssf"
         class="org.mybatis.spring.SqlSessionFactoryBean"
         p:dataSource-ref="ds"
    />
    <bean id="mapper1"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.BoardMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <bean id="mapper2"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.MemberMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <bean id="mapper3"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.RecipeMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <!-- 위와같이 mapper가 여러개일경우 mybatis-spring이용 -->
    <!-- <mybatis-spring:scan base-package="com.sist.dao" factory-ref="ssf"/> -->
    <bean id="viewResolver"
         class="org.springframework.web.servlet.view.InternalResourceViewResolver"
         p:prefix="/"
         p:suffix=".jsp"
    />
    
</beans>
cs

 

com.sist.dao

BoardVO

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.sist.dao;
/*
     NO      NOT NULL NUMBER         
    NAME    NOT NULL VARCHAR2(34)   
    SUBJECT NOT NULL VARCHAR2(1000) 
    CONTENT NOT NULL CLOB           
    PWD     NOT NULL VARCHAR2(10)   
    REGDATE          DATE           
    HIT              NUMBER         
    GI               NUMBER         
    GS               NUMBER         
    GT               NUMBER         
    ROOT             NUMBER         
    DEPTH            NUMBER   
 */
import java.util.*;
 
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
public class BoardVO {
    private int no;
    @NotNull
    private String name;
    @NotNull
    private String subject;
    @NotNull
    private String content;
    @NotNull
    @Size(min=4,max=8)
    private String pwd;
    private Date regdate;
    private int hit;
    private int gi;
    private int gs;
    private int gt;
    private int root;
    private int depth;
    public int getNo() {
        return no;
    }
    public void setNo(int no) {
        this.no = no;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSubject() {
        return subject;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getPwd() {
        return pwd;
    }
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
    public Date getRegdate() {
        return regdate;
    }
    public void setRegdate(Date regdate) {
        this.regdate = regdate;
    }
    public int getHit() {
        return hit;
    }
    public void setHit(int hit) {
        this.hit = hit;
    }
    public int getGi() {
        return gi;
    }
    public void setGi(int gi) {
        this.gi = gi;
    }
    public int getGs() {
        return gs;
    }
    public void setGs(int gs) {
        this.gs = gs;
    }
    public int getGt() {
        return gt;
    }
    public void setGt(int gt) {
        this.gt = gt;
    }
    public int getRoot() {
        return root;
    }
    public void setRoot(int root) {
        this.root = root;
    }
    public int getDepth() {
        return depth;
    }
    public void setDepth(int depth) {
        this.depth = depth;
    }
    
}
 
cs

 

BoardMapper (interface)

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
package com.sist.dao;
 
import java.util.*;
 
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
public interface BoardMapper {
    @Select("SELECT no,subject,name,regdate,hit,gt,num "
            +"FROM (SELECT no,subject,name,regdate,hit,gt,rownum as num "
            +"FROM (SELECT no,subject,name,regdate,hit,gt "
            +"FROM spring_reply ORDER BY gi DESC, gs ASC)) "
            +"WHERE num BETWEEN #{start} AND #{end}")
    public List<BoardVO> boardListData(Map map);
    
    // SelectKey 자동증감번호
    
    @SelectKey(keyProperty="no",resultType=int.class,before=true,
            statement="SELECT NVL(MAX(no)+1,1) as no FROM spring_reply")
    @Insert("INSERT INTO spring_reply(no,name,subject,content,pwd,gi) "
            +"VALUES(#{no},#{name},#{subject},#{content},#{pwd},"
            +"(SELECT NVL(MAX(gi)+1,1) FROM spring_reply))")
    public void boardInsert(BoardVO vo);
    
    // 상세보기
    @Update("UPDATE spring_reply SET "
            +"hit=hit+1 "
            +"WHERE no=#{no}")
    public void boardHitIncrement(int no);
    
    @Select("SELECT no,name,subject,content,regdate,hit "
            +"FROM spring_reply "
            +"WHERE no=#{no}")
    public BoardVO boardDetailData(int no);
    
    //답변
    @Select("SELECT gi,gs,gt FROM spring_reply "
            +"WHERE no=#{no}")
    public BoardVO boardParentData(int no);
    
    /*                    gi    gs  gt
     * AAAAA            1    0    0
     *  =>FFFFF            1     1    1 (boardGsIncrement코딩으로 가능)
     *     =>BBBBB            1    2    1
     *         =>DDDDD        1    3    2
     *     =>CCCCC            1    4    1
     * EEEEE            2    0
     */
    
    @Update("UPDATE spring_reply SET "
            +"gs=gs+1 "
            +"WHERE gi=#{gi} AND gs>#{gs}")
    public void boardGsIncrement(BoardVO vo);
    
    @SelectKey(keyProperty="no",resultType=int.class,before=true,
            statement="SELECT NVL(MAX(no)+1,1) as no FROM spring_reply")
    @Insert("INSERT INTO spring_reply(no,name,subject,content,pwd,gi,gs,gt,root) "
            +"VALUES(#{no},#{name},#{subject},#{content},#{pwd},"
            +"#{gi},#{gs},#{gt},#{root})")
    public void boardReplyInsert(BoardVO vo);
    
    @Update("UPDATE spring_reply SET "
            +"depth=depth+1 "
            +"WHERE no=#{no}")
    public void boardDepthIncrement(int no);
}
 
cs

 

 

BoardDAO

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
package com.sist.dao;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.*;
 
@Repository
public class BoardDAO {
    @Autowired
    private BoardMapper mapper;
    public List<BoardVO> boardListData(Map map){
        return mapper.boardListData(map);
    }
    public void boardInsert(BoardVO vo){
        mapper.boardInsert(vo);
    }
    public BoardVO boardDetailData(int no){
        // 조회수 증가
        mapper.boardHitIncrement(no);
        return mapper.boardDetailData(no);
    }
    /*                    gi  gs  gt
     * AAAAA   1        1    0    0
     *     =>BBB  2        1    1    1
     *      =>CCC 3        1    2    2
     * gi: groupid 같은아이디인지
     * gs: groupstep 답변출력순서
     * gt: grouptap 칸띄우기(간격)
     */
    
    //반드시 트랜잭션으로하고, 롤백실행(취소)하면 에러처리 =>오류잡기
    //@Around, @After-Returning...등 어노테이션들 대신 트랜잭션이 처리해줌
    @Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class)
    public void boardReplyInsert(int root,BoardVO vo){
        // conn.setAutoCommit(false)
        BoardVO pvo=mapper.boardParentData(root);
        mapper.boardGsIncrement(pvo);
        vo.setGi(pvo.getGi());
        vo.setGs(pvo.getGs()+1);
        vo.setGt(pvo.getGt()+1);
        mapper.boardReplyInsert(vo);
        mapper.boardDepthIncrement(root);
        // conn.commit() => @Around
        // catch() ==> conn.rollback() => @After-Returning
    }
}
 
cs

 

MemberMapper (interface)

1
2
3
4
5
6
7
8
9
10
11
12
13
package com.sist.dao;
 
import org.apache.ibatis.annotations.Select;
 
public interface MemberMapper {
    @Select("SELECT COUNT(*) FROM member "
            +"WHERE id=#{id}")
    public int idCheck(String id);
    @Select("SELECT pwd FROM member "
            +"WHERE id=#{id}")
    public String memberGetPassword(String id);
}
 
cs

 

MemberDAO

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
package com.sist.dao;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
 
@Repository
public class MemberDAO {
    @Autowired
    private MemberMapper mapper;
    public String isLogin(String id,String pwd){
        String result="";
        int count=mapper.idCheck(id);
        if(count==0){
            result="NOID";
        }else{
            String db_pwd=mapper.memberGetPassword(id);
            if(db_pwd.equals(pwd)){
                result="OK"//Session
            }else{
                result="NOPWD";
            }
        }
        return result;
    }
}
 
cs

 

com.sist.web

BoardController

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
72
73
package com.sist.web;
 
import java.util.*;
import com.sist.dao.*;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
 
@Controller
public class BoardController {
    @Autowired
    private BoardDAO dao;
    
    @GetMapping("board/list.do")
    public String board_list(String page, Model model){
        if(page==null)
            page="1";
        int curpage=Integer.parseInt(page);
        Map map=new HashMap();
        int rowSize=15;
        int start=(rowSize*curpage)-(rowSize-1);
        int end=rowSize*curpage;
        map.put("start", start);
        map.put("end", end);
        
        List<BoardVO> list=dao.boardListData(map);
        
        // JSP로 전송
        model.addAttribute("list", list);
        
        return "board/list";
    }
    @GetMapping("board/insert.do")
    public String board_insert(){
        return "board/insert";
    }
    
    @PostMapping("board/insert_ok.do")
    public String board_insert_ok(@ModelAttribute("vo") BoardVO vo){
        dao.boardInsert(vo);
        return "redirect:list.do";
    }
    @GetMapping("board/detail.do")
    public String board_detail(int no, Model model){
        // Model => 해당 JSP로 데이터 전송
        // 데이터베이스 연동
        BoardVO vo=dao.boardDetailData(no);
        // 데이터 전송
        model.addAttribute("vo", vo);
        return "board/detail";
    }
    
    @GetMapping("board/reply.do")
    public String board_reply(int no,Model model){
        model.addAttribute("no", no);
        return "board/reply"//보내는 곳
    }
    /*
     * GetMapping => location.href="", a태그 <a href="../board/reply.do?no=${vo.no }" 
     * PostMapping => form태그 <form method="post"
     */
    @PostMapping("board/reply_ok.do")
    public String board_reply_ok(int pno, BoardVO vo){
        // vo에 pno가 없었기 때문에 reply.jsp <input type=hidden name=pno value="${no }"> pno는 단독으로 받아야함
        dao.boardReplyInsert(pno, vo);
        return "redirect:../board/list.do";
    }
}
 
cs

 

MemberController

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
package com.sist.web;
 
import javax.servlet.http.HttpSession;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sist.dao.*;
 
@Controller
public class MemberController {
    @Autowired
    private MemberDAO dao;
    @RequestMapping("member/login.do")
    public String member_login(){
        return "member/login";
    }
    @RequestMapping("member/login_ok.do")
    public String member_login_ok(String id,String pwd,HttpSession session,Model model){
        String result=dao.isLogin(id, pwd);
        if(result.equals("OK")){
            session.setAttribute("id", id);
        }
        model.addAttribute("result",result);
        return "member/login_ok";
    }
}
 
cs

 

webapp/board/

insert.jsp

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row {
   margin: 0px auto;
   width:700px;
}
</style>
</head>
<body>
 <div class="container">
  <div class="row">
   <h3 class="text-center">글쓰기</h3>
   <form method="post" action="insert_ok.do">
   <table class="table table-hover">
     <tr>
       <th class="danger text-right" width=15%>이름</th>
       <td width=85%>
         <input type=text name=name size=15 class="input-sm">
       </td>
     </tr>
     <tr>
       <th class="danger text-right" width=15%>제목</th>
       <td width=85%>
         <input type=text name=subject size=45 class="input-sm">
       </td>
     </tr>
     <tr>
       <th class="danger text-right" width=15%>내용</th>
       <td width=85%>
         <textarea rows="10" cols="50" name=content></textarea>
       </td>
     </tr>
     <tr>
       <th class="danger text-right" width=15%>비밀번호</th>
       <td width=85%>
         <input type=password name=pwd size=10 class="input-sm">
       </td>
     </tr>
     <tr>
       <td colspan="2" class="text-center">
         <input type=submit value=글쓰기 class="btn btn-sm btn-primary">
         <input type=button value=취소 class="btn btn-sm btn-primary"
           onclick="javascript:history.back()"
         >
       </td>
     </tr>
   </table>
   </form>
  </div>
  </div>
</body>
</html>
cs

 

*로그인해야 새글 쓸 수 있게

1
2
3
4
5
6
7
8
9
10
 <h3 class="text-center">자유게시판</h3>
    <c:if test="${sessionScope.id!=null }">
    <table class="table">
      <tr>
        <td class="text-left">
          <a href="insert.do" class="btn btn-sm btn-danger">새글</a>
        </td>
      </tr>
    </table>
    </c:if>
cs

 

list.jsp

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
72
73
74
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row {
   margin: 0px auto;
   width:800px;
}
.btd {
  font-size: 8pt;
}
</style>
</head>
<body>
  <div class="container">
  <div class="row">
    <h3 class="text-center">자유게시판</h3>
    <c:if test="${sessionScope.id!=null }">
        <table class="table">
          <tr>
            <td class="text-left">
              <a href="insert.do" class="btn btn-sm btn-danger">새글</a>
            </td>
          </tr>
        </table>
    </c:if>
    <table class="table table-striped">
      <tr class="warning">
        <th class="text-center" width=10%>번호</th>
        <th class="text-center" width=45%>제목</th>
        <th class="text-center" width=15%>이름</th>
        <th class="text-center" width=20%>작성일</th>
        <th class="text-center" width=10%>조회수</th>
      </tr> 
      <c:forEach var="vo" items="${list }">
        <tr>
            <td class="text-center btd" width=10%>${vo.no }</td>
            <td class="text-left btd" width=45%>
             <c:if test="${vo.getGt()>0 }">
               <c:forEach var="i" begin="1" end="${vo.getGt() }">
                 &nbsp;&nbsp;&nbsp;
               </c:forEach>
               <img src="reply.png" width=10 height=10>
             </c:if>
             <a href="detail.do?no=${vo.no }">${vo.subject }</a>
            </td>
            <td class="text-center btd" width=15%>${vo.name }</td>
            <td class="text-center btd" width=20%>
              <fmt:formatDate value="${vo.regdate }" pattern="yyyy-MM-dd"/></td>
            <td class="text-center btd" width=10%>${vo.hit }</td>
      </tr> 
      </c:forEach>
    </table>
    <table class="table">
      <tr>
        <td class="text-left"></td>
        <td class="text-right">
          <a href="#" class="btn btn-sm btn-primary">이전</a>
            ${curpage } page / ${totalpage } pages
          <a href="#" class="btn btn-sm btn-primary">다음</a>
        </td>
      </tr>
    </table>
  </div>
  </div>
</body>
</html>
cs

 

detail.jsp

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row {
   margin: 0px auto;
   width:700px;
}
</style>
</head>
<body>
   <div class="container">
     <div class="row">
       <h1 class="text-center">내용보기</h1>
       <table class="table table-striped">
        <tr>
         <th width=20% class="text-center danger">번호</th>
         <td width=30% class="text-center">${vo.no }</td>
         <th width=20% class="text-center danger">작성일</th>
         <td width=30% class="text-center">
           <fmt:formatDate value="${vo.regdate }" pattern="yyyy-MM-dd"/>
         </td>
        </tr>
        <tr>
         <th width=20% class="text-center danger">이름</th>
         <td width=30% class="text-center">${vo.name }</td>
         <th width=20% class="text-center danger">조회수</th>
         <td width=30% class="text-center">${vo.hit }</td>
        </tr>
        <tr>
         <th width=20% class="text-center danger">제목</th>
         <td colspan="3">${vo.subject }</td>
        </tr>
        <tr>
          <td colspan="4" class="text-left" valign="top" height="200">${vo.content }</td>
        </tr>
        <tr>
          <td colspan="4" class="text-right">
           <c:if test="${sessionScope.id!=null }">
            <a href="../board/reply.do?no=${vo.no }" class="btn btn-xs btn-danger">답변</a>
            <a href="#" class="btn btn-xs btn-success">수정</a>
            <a href="#" class="btn btn-xs btn-info">삭제</a>
           </c:if>
            <a href="../board/list.do" class="btn btn-xs btn-warning">목록</a>
          </td>
        </tr>
       </table>
     </div>
   </div>
</body>
</html>
 
cs

 

reply.jsp

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row {
   margin: 0px auto;
   width:700px;
}
</style>
</head>
<body>
 <div class="container">
  <div class="row">
   <h3 class="text-center">답변하기</h3>
   <form method="post" action="reply_ok.do">
   <table class="table table-hover">
     <tr>
       <th class="danger text-right" width=15%>이름</th>
       <td width=85%>
         <input type=text name=name size=15 class="input-sm">
         <input type=hidden name=pno value="${no }">
       </td>
     </tr>
     <tr>
       <th class="danger text-right" width=15%>제목</th>
       <td width=85%>
         <input type=text name=subject size=45 class="input-sm">
       </td>
     </tr>
     <tr>
       <th class="danger text-right" width=15%>내용</th>
       <td width=85%>
         <textarea rows="10" cols="50" name=content></textarea>
       </td>
     </tr>
     <tr>
       <th class="danger text-right" width=15%>비밀번호</th>
       <td width=85%>
         <input type=password name=pwd size=10 class="input-sm">
       </td>
     </tr>
     <tr>
       <td colspan="2" class="text-center">
         <input type=submit value=답변 class="btn btn-sm btn-primary">
         <input type=button value=취소 class="btn btn-sm btn-primary"
           onclick="javascript:history.back()"
         >
       </td>
     </tr>
   </table>
   </form>
  </div>
  </div>
</body>
</html>
cs

 

webapp/member

login.jsp

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row {
   margin: 0px auto;
   width:350px;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery/js"></script>
<script type="text/javascript">
$(function(){
   $('.btn').click(function(){
      let id=$('#id').val();
      if(id.trim()=="")
      {
         $('#id').focus();
         return;
      }
      let pwd=$('#pwd').val();
      if(id.trim()=="")
      {
         $('#pwd').focus();
         return;
      }
      //전송
      $('#frm').submit();
   }) ;
});
</script>
</head>
<body>
   <div class="container">
     <div class="row">
       <h1 class="text-center">Login</h1>
       <form method="post" action="login_ok.do" id=frm>
       <table class="table">
         <tr>
           <td width=20% class="text-right">ID</td>
           <td width=80%>
             <input type=text name=id size=15>
           </td>
         </tr>
         <tr>
           <td width=20% class="text-right">PW</td>
           <td width=80%>
             <input type=password name=pwd size=15 id=pwd>
           </td>
         </tr>
         <tr>
           <td colspan="2" class=text-center">
             <input type=submit value="로그인" class="btn btn-sm btn-primary">
           </td>
         </tr>
       </table>
       </form>
     </div>
   </div>
</body>
</html>
cs

 

login_ok.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:choose>
    <c:when test="${result=='NOID' }">
        <script>
            alert("ID가 존재하지 않습니다!!");
            history.back();
        </script>
    </c:when>
    <c:when test="${result=='NOPWD' }">
        <script>
            alert("비밀번호가 틀립니다!!");
            history.back();
        </script>
    </c:when>
    <c:otherwise>
        <c:redirect url="../board/list.do"/>
    </c:otherwise>
</c:choose>
cs

 

WEB-INF/config

application-context.xml

1
2
3
4
<bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="ds"
    />
cs

트랜잭션: 하나가 실패하면 rollback, 일괄처리

query생성할 때 insert, update 여러개일 경우사용

(부분적으로 커밋되면 부분적으로 데이터베이스 저장되기 때문에 => 한번에 처리하기 위해서 사용!)

 

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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    <context:component-scan base-package="com.sist.*"/>
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>text/html;charset=UTF-8</value>
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <bean id="ds" class="org.apache.commons.dbcp.BasicDataSource"
        p:driverClassName="oracle.jdbc.driver.OracleDriver"
        p:url="jdbc:oracle:thin:@localhost:1521:XE"
        p:username="hr"
        p:password="happy"
    />
    <aop:aspectj-autoproxy/>
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="ds"
    />
    <bean id="ssf"
         class="org.mybatis.spring.SqlSessionFactoryBean"
         p:dataSource-ref="ds"
    />
    <bean id="mapper1"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.BoardMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <bean id="mapper2"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.MemberMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <bean id="mapper3"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.RecipeMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <!-- 위와같이 mapper가 여러개일경우 mybatis-spring이용 -->
    <!-- <mybatis-spring:scan base-package="com.sist.dao" factory-ref="ssf"/> -->
    <bean id="viewResolver"
         class="org.springframework.web.servlet.view.InternalResourceViewResolver"
         p:prefix="/"
         p:suffix=".jsp"
    />
    
</beans>
 
cs

SpringCookieProject

 

src/main/java

com.sist/dao

MovieVO

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.sist.dao;
/*
 *   NO       NOT NULL NUMBER        
   CATENO            NUMBER        
   TITLE    NOT NULL VARCHAR2(200) 
   POSTER   NOT NULL VARCHAR2(300) 
   REGDATE           VARCHAR2(200) 
   GENRE    NOT NULL VARCHAR2(100) 
   GRADE    NOT NULL VARCHAR2(100) 
   ACTOR             VARCHAR2(100) 
   SCORE             VARCHAR2(20)  
   DIRECTOR NOT NULL VARCHAR2(100) 
   STORY             CLOB          
   KEY               VARCHAR2(50)  
   HIT               NUMBER        
 */
public class MovieVO {
    private String poster;
    private String title;
    private String regdate;
    private String grade;
    private String genre;
    private String actor;
    private String score;
    private String director;
    private String story,key;
    private int hit,no,cateno;
   public String getPoster() {
      return poster;
   }
   public void setPoster(String poster) {
      this.poster = poster;
   }
   public String getTitle() {
      return title;
   }
   public void setTitle(String title) {
      this.title = title;
   }
   public String getRegdate() {
      return regdate;
   }
   public void setRegdate(String regdate) {
      this.regdate = regdate;
   }
   public String getGrade() {
      return grade;
   }
   public void setGrade(String grade) {
      this.grade = grade;
   }
   public String getGenre() {
      return genre;
   }
   public void setGenre(String genre) {
      this.genre = genre;
   }
   public String getActor() {
      return actor;
   }
   public void setActor(String actor) {
      this.actor = actor;
   }
   public String getScore() {
      return score;
   }
   public void setScore(String score) {
      this.score = score;
   }
   public String getDirector() {
      return director;
   }
   public void setDirector(String director) {
      this.director = director;
   }
   public String getStory() {
      return story;
   }
   public void setStory(String story) {
      this.story = story;
   }
   public String getKey() {
      return key;
   }
   public void setKey(String key) {
      this.key = key;
   }
   public int getHit() {
      return hit;
   }
   public void setHit(int hit) {
      this.hit = hit;
   }
   public int getNo() {
      return no;
   }
   public void setNo(int no) {
      this.no = no;
   }
   public int getCateno() {
      return cateno;
   }
   public void setCateno(int cateno) {
      this.cateno = cateno;
   }
     
}
cs

 

MovieMapper(interface)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.sist.dao;
 
import java.util.*;
 
import org.apache.ibatis.annotations.Select;
 
public interface MovieMapper {
    @Select("SELECT no,title,poster,rownum "
            +"FROM daum_movie "
            +"WHERE rownum<=20")
    public List<MovieVO> movieListData();
    
    @Select("SELECT * FROM daum_movie "
            +"WHERE no=#{no}")
    public MovieVO movieDetailData(int no);
    
}
 
cs

 

MovieDAO

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.sist.dao;
 
import java.util.*;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
 
@Repository
public class MovieDAO {
    @Autowired
    private MovieMapper mapper;
    public List<MovieVO> movieListData(){
        return mapper.movieListData();
    }
    public MovieVO movieDetailData(int no){
        return mapper.movieDetailData(no);
    }
}
 
cs

 

 

src/main/webapp/WEB-INF/config

application-context.xml

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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
    <context:component-scan base-package="com.sist.*"/>
    <mvc:annotation-driven/>
    <!-- database생성 -->
    <bean id="ds" class="org.apache.commons.dbcp.BasicDataSource"
        p:driverClassName="oracle.jdbc.driver.OracleDriver"
        p:url="jdbc:oracle:thin:@localhost:1521:XE"
        p:username="hr"
        p:password="happy"
    />
    <bean id="ssf"
         class="org.mybatis.spring.SqlSessionFactoryBean"
         p:dataSource-ref="ds"
    />
    <bean id="mapper"
         class="org.mybatis.spring.mapper.MapperFactoryBean"
         p:mapperInterface="com.sist.dao.MovieMapper"
         p:sqlSessionFactory-ref="ssf"
    />
    <!-- mapper가 여러개일경우 mybatis-spring이용 -->
    <!-- <mybatis-spring:scan base-package="com.sist.dao" factory-ref="ssf"/> -->
    <bean id="viewResolver"
         class="org.springframework.web.servlet.view.InternalResourceViewResolver"
         p:prefix="/"
         p:suffix=".jsp"
    /> 
</beans>
 
cs

 

com.sist.web

MovieController (HttpServletResponse => 쿠키전송)

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
72
73
package com.sist.web;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
import java.util.*;
 
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.sist.dao.*;
 
@Controller
public class MovieController {
    @Autowired
    private MovieDAO dao;
    @RequestMapping("movie/list.do")
    public String movie_list(Model model, HttpServletRequest request){
        List<MovieVO> list=dao.movieListData();
        model.addAttribute("list", list);
        
        //쿠키
        List<MovieVO> cList=new ArrayList<MovieVO>();
        Cookie[] cookies=request.getCookies();
        if(cookies!=null){ //쿠키에 값이 있다면
            //역순으로 가져오면 최신쿠키가 앞으로
            for(int i=cookies.length-1; i>=0; i--){
                // m으로 시작하는 쿠키만 가져와라
                // map방식은 key가 저장되기 때문에
                if(cookies[i].getName().startsWith("m")){
                    MovieVO vo=dao.movieDetailData(Integer.parseInt(cookies[i].getValue()));
                    cList.add(vo);
                }
            }
        }
        model.addAttribute("cList", cList);
        
        return "movie/list";
    }
    // _ok, _before => jsp(X) => 처리 => redirect로 이동
    @RequestMapping("movie/detail_before.do")
    public String movie_detail_before(int no, RedirectAttributes ra, HttpServletResponse response){
        //아이디 중복을 위해서 +no를 붙임
        Cookie cookie=new Cookie("m"+no, String.valueOf(no));
        cookie.setMaxAge(60*60*24); //하루동안 저장
        response.addCookie(cookie); //클라이언트에 저장
        // 쿠키의 단점 => 저장을 문자열만 저장이 가능 String.valueOf(no) 변환
        
        
        //ra.addFlashAttribute("no", no);
        /*
         * RedirectAttributes, addFlashAttribute
              => redirect:detail.do?no="+no
             get->post방식으로 바꿔서 +no값 필요없어짐
             (URL뒤에 데이터를 볼 수 없다)
         */
        return "redirect:detail.do?no="+no;
        //처리하고 이동하는거라서 redirect는 .jsp 파일 필요없음
        //보여주는 부분만 jsp파일 필요
    }
    
    @RequestMapping("movie/detail.do")
    public String movie_detail(int no, Model model){
        MovieVO vo=dao.movieDetailData(no);
        model.addAttribute("vo", vo);
        return "movie/detail";
    }
}
 
cs

RedirectAttributes 사용하려면 application-context.xml에

<mvc:annotation-driven/> 추가해야함!

 

쿠키 movie_detail_before

=>쿠키에 있는 내용 Controller movie/list에 리스트목록 cList로 보내기

 

webapp/movie

list.jsp

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row{
   margin: 0px auto; 
}
</style>
</head>
<body>
    <div style="height:30px"></div>
    <div class="container-fluid">
        <div class="row">
            <c:forEach var="vo" items="${list }">
                <div class="col-md-3">
                    <div class="thumbnail">
                      <a href="detail_before.do?no=${vo.no }">
                        <img src="${vo.poster }" alt="Lights" style="width:100%">
                        <div class="caption">
                          <p style="font-size:8pt">${vo.title }</p>
                        </div>
                      </a>
                  </div>
                </div>
            </c:forEach>
        </div>
        <hr>
        <div class="row">
            <h3>이미 본 영화목록</h3>
            <c:forEach var="vo" items="${cList }" varStatus="s">
                <c:if test="${s.index<6 }">
                <div class="col-md-2">
                    <div class="thumbnail">
                      <a href="detail_before.do?no=${vo.no }">
                        <img src="${vo.poster }" alt="Lights" style="width:100%">
                        <div class="caption">
                          <p style="font-size:8pt">${vo.title }</p>
                        </div>
                      </a>
                  </div>
                </div>
                </c:if>
            </c:forEach>
        </div>
    </div>
</body>
</html>
cs

 

detail.jsp

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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style type="text/css">
.row{
   margin: 0px auto;
   width:800px;
}
</style>
</head>
<body>
    <div style="height:30px"></div>
    <div class="container">
        <div class="row">
            <h3 class="text-center">&lt;${vo.title }&gt;상세보기</h3>
            <table class="table">
                <tr>
                    <td>
                        <iframe src="http://youtube.com/embed/${vo.key }" width=750 height=350></iframe>
                    </td>
                </tr>
            </table>
            <table class="table">
                <tr>
                    <td width=30% class="text-center" rowspan="7">
                        <img src="${vo.poster }" width=100%>
                    </td>
                    <td colspan="2">${vo.title }</td>
                </tr>
                <tr>
                    <td width=20% class="text-right">감독</td>
                    <td width=20% class="text-left">${vo.director }</td>
                </tr>
                <tr>
                    <td width=20% class="text-right">출연</td>
                    <td width=20% class="text-left">${vo.actor }</td>
                </tr>
                <tr>
                    <td width=20% class="text-right">장르</td>
                    <td width=20% class="text-left">${vo.genre }</td>
                </tr>
                <tr>
                    <td width=20% class="text-right">등급</td>
                    <td width=20% class="text-left">${vo.grade }</td>
                </tr>
                <tr>
                    <td width=20% class="text-right">평점</td>
                    <td width=20% class="text-left">${vo.score }</td>
                </tr>
                <tr>
                    <td width=20% class="text-right">개봉일</td>
                    <td width=20% class="text-left">${vo.regdate }</td>
                </tr>
                <tr>
                    <td colspan="3">${vo.story }</td>
                </tr>
                <tr>
                    <td colspan="3" class="text-right">
                        <a href="list.do" class="btn btn-sm btn-primary">목록</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</body>
</html>
cs

1. Spring Container : 사용자정의 클래스를 관리(생성, 소멸)

   = ApplicationContext

   = WebApplicationContext

   = AnnotationConfigApplicationContext

2. 생성시에 필요한 데이터 전송

   DI => setXxx(), 생성자의 매개변수

           p:     c:

3. AOP : 중복 제거 (자동 호출)

  => 시점 (JoinPoint), 메소드 호출 => PointCut

 

반응형

'Back-end > Spring' 카테고리의 다른 글

Spring 17일차 - SQL PROCEDURE 게시판  (0) 2020.11.19
Spring 15일차 - AOP  (0) 2020.11.17
Spring 14일차 - Tiles  (1) 2020.11.16
Spring 13일차 - Mybatis연동, JSON  (0) 2020.11.13
Spring 12일차 - PL/SQL Procedure 게시판 만들기  (0) 2020.11.12
Comments