π»
μ€νλ§ νλ μμν¬ - [Spring] MVC νλ‘μ νΈ(5) : νμΌμ λ‘λ λ³Έλ¬Έ
μ€νλ§ νλ μμν¬ - [Spring] MVC νλ‘μ νΈ(5) : νμΌμ λ‘λ
λν¨λ 2020. 7. 30. 10:32κ²μν νμΌμ λ‘λ
WEB-INF > lib μ νμΌμ λ‘λλ₯Ό μν .jarνμΌ μΆκ°
μμ μμ : Setting -> Controller -> Service -> ServiceImp -> Dao -> mapper.xml -> DaoImp
SpringController-servlet.xml
fileBoardController μΆκ°
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
<!-- AOP -->
<bean id="hAspect" class="com.java.aop.HAspect"/>
<aop:config>
<aop:aspect id="exAspect" ref="hAspect">
<aop:pointcut expression="within(com.java.*)" id="pMethod"/>
<aop:around method="advice" pointcut-ref="pMethod"/>
</aop:aspect>
</aop:config>
<!-- HandlerMapping / UIμμ²μ΄ λ€μ΄μ€λ©΄ ν΄λΉ ν΄λμ€λ₯Ό μ°ΎμλΌ -->
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/member/*.do">memberController</prop>
<prop key="/fileBoard/*.do">fileBoardController</prop>
</props>
</property>
</bean>
<!-- ViewResolver : MVC RequestDispatcher / forward -->
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
View
index.jsp
<%@ 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>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:set var="root" value="${pageContext.request.contextPath}"/>
<c:set var= "id" value="${id}" scope="session"/>
<a href="${root}/member/test.do"> Spring MVC Start!!! </a>
<c:if test="${memberLevel==null}">
<h3>νμκ΄λ¦¬</h3>
<a href="${root}/member/register.do">νμκ°μ
</a>
<h3>λ‘κ·ΈμΈ</h3>
<a href="${root}/member/login.do">λ‘κ·ΈμΈ</a>
</c:if>
<c:if test="${memberLevel!=null}">
<h3>νμμμ </h3>
<a href="${root}/member/update.do">νμμμ </a>
<h3>λ‘κ·Έμμ</h3>
<a href="${root}/member/logout.do">λ‘κ·Έμμ</a>
</c:if>
<c:if test="${memberLevel=='MA'}">
<h3>κ΄λ¦¬μνμ΄μ§</h3>
</c:if>
<h3>νμΌκ²μν</h3>
<a href="${root}/fileBoard/write.do">νμΌκ²μν μ°κΈ°</a>
<br/><br/>
<a href="${root}/fileBoard/list.do">νμΌκ²μν 보기</a>
</body>
</html>
write.jsp
<%@ 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>
<c:set var="root" value="${pageContext.request.contextPath }" />
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ κΈμμ± νμ΄μ§</title>
<link rel="stylesheet" href="${root}/css/board/boardStyle.css" />
<script type="text/javascript" >
function boardCheck(obj){
//alert("OK");
}
function replyFunc(root, boardNumber, groupNumber, sequenceNumber, sequenceLevel){
var url = root + "/fileboard/write.do?boardNumber=" + boardNumber +
"&groupNumber=" + groupNumber + "&sequenceNumber=" + sequenceNumber +
"&sequenceLevel=" + sequenceLevel;
location.href = url;
}
function delFunc(root, boardNumber, pageNumber){
var url = root+ "/fileboard/delete.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
location.href = url;
/*var value = confirm("μμ νμκ² μ΅λκΉ?");
if(value == true){
var url = root+ "/board/deleteOk.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
alert(url);
}else{
alert("μ·¨μλμμ΅λλ€.");
}*/
}
function updFunc(root, boardNumber, pageNumber){
var url = root + "/fileboard/update.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
location.href = url;
}
</script>
</head>
<body>
${boardNumber}, ${groupNumber}, ${sequenceNumber}, ${sequenceLevel}
<form id="createform" action="${root}/fileBoard/writeOk.do" method="post"
onsubmit="return boardCheck(this)" enctype="multipart/form-data">
<div id="title"><a href="${root}/fileboard/list.do">κΈλͺ©λ‘</a></div>
<div class="menu" style="border-bottom-width: 0px;">
<input type="hidden" name="boardNumber" value="${boardNumber}" />
<input type="hidden" name="groupNumber" value="${groupNumber}" />
<input type="hidden" name="sequenceNumber" value="${sequenceNumber}" />
<input type="hidden" name="sequenceLevel" value="${sequenceLevel}" />
<div id="id">μμ±μ</div>
<span>
<input type="text" name="writer" size="12" />
</span>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μ λͺ©</div>
<span>
<input type="text" name="subject" size="50" />
</span>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μ΄λ©μΌ</div>
<span>
<input type="email" name="email" size="50" />
</span>
</div>
<div class="content" style="border-bottom-width: 0px;">
<div id="text">λ΄μ©</div>
<span>
<textarea name="content" rows="12" cols="65"></textarea>
</span>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">λΉλ°λ²νΈ</div>
<span>
<input type="password" name="password" size="30" />
</span>
</div>
<!-- νμΌ μ
λ‘λ -->
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">νμΌλͺ
</div>
<span>
<input type="file" name="file" size="50" />
</span>
</div>
<div class="menu" style="border-bottom-width: 3px; text-align: center;">
<span>
<input type="submit" value="κΈμ°κΈ°" />
<input type="reset" value="λ€μμμ±" />
<input type="button" value="λͺ©λ‘보기" onclick="location.href='${root}/fileboard/list.do'"/>
</span>
</div>
</form>
</body>
</html>
writeOk.jsp
<%@ 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>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ κΈμ°κΈ° μλ£</title>
</head>
<body>
<c:if test="${check>0}">
<script type="text/javascript">
alert("κΈμ°κΈ°μ μ±κ³΅νμ
¨μ΅λλ€.")
location.href = "${root}/fileBoard/list.do";
</script>
</c:if>
<c:if test="${check==0}">
<script type="text/javascript">
alert("κΈμ°κΈ°λ₯Ό μ€ν¨.")
location.href = "${root}/fileBoard/write.do";
</script>
</c:if>
</body>
</html>
list.jsp
<%@ 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>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ λͺ©λ‘ νμ΄μ§</title>
</head>
<body>
<div align="right">
<table>
<tr>
<td>
<a href="${root}/fileBoard/write.do">κΈμ°κΈ°</a>
</td>
</tr>
</table>
</div>
<c:if test="${count==0||boardList.size()==0}">
<div align="center">
κ²μνμ μ μ₯λ κΈμ΄ μμ΅λλ€.
</div>
</c:if>
<c:if test="${count>0}">
<div align="center">
<table border="1">
<tr>
<td align="center" width="50"><strong>λ²νΈ</strong></td>
<td align="center" width="250"><strong>μ λͺ©</strong></td>
<td align="center" width="70"><strong>μμ±μ</strong></td>
<td align="center" width="150"><strong>μμ±μΌ</strong></td>
<td align="center" width="50"><strong>μ‘°νμ</strong></td>
</tr>
<c:forEach var="boardDto" items="${boardList}">
<tr>
<!-- κΈλ²νΈ -->
<td align="center" width="50">${boardDto.boardNumber}</td>
<td align="center" width="250">
<!-- λ΅κΈ -->
<c:if test="${boardDto.sequenceLevel > 0}">
<c:forEach begin="0" end="${boardDto.sequenceLevel}">
</c:forEach>
[λ΅κΈ]
</c:if>
<!-- μ λͺ© -->
<a href="${root}/fileBoard/read.do?boardNumber=${boardDto.boardNumber}&pageNumber=${currentPage}">${boardDto.subject}</a>
</td>
<!-- μμ±μ -->
<td align="center" width="70">${boardDto.writer}</td>
<!-- μμ±μΌ -->
<td align="center" width="150">
<fmt:formatDate value="${boardDto.writeDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
</td>
<!-- μ‘°νμ -->
<td align="center" width="50">${boardDto.readCount}</td>
</tr>
</c:forEach>
</table>
</div>
</c:if>
<div align="center">
<%--
1. ν νμ΄μ§λΉ κ²μλ¬Ό μ : 10
2. μ΄ νμ΄μ§ μ: 10page = μ 체λ μ½λ μ 100/ ν νμ΄μ§λΉ κ²μλ¬Ό μ 10
11page = μ 체λ μ½λ μ 101/ ν νμ΄μ§λΉ κ²μλ¬Ό μ 10
3. νμ΄μ§λ²νΈ λΈλ : 10
[1][2][3][4][5]...[10]
μμ²νμ΄μ§λ²νΈ 5μ΄λ©΄ μμλ²νΈ 1, κΈλ²νΈ 10
pageBlock, currentPage : μμλ²νΈ, λλ²νΈ
int startPage=(int)((currentPage-1)/pageBlock)*pageBlock + 1
(3-1)/10 = 0*10 + 1 = 1
(33-1)/10= 3*10 + 1 = 31
int endPage=startPage+pageBlock-1
1+10-1 = 10
31+10-1 = 40
4. boardSize, currentPage, count: Command Data
--%>
<fmt:parseNumber var="pageCount" value="${count/boardSize+(count%boardSize==0? 0:1)}" integerOnly="true"/>
<c:set var="pageBlock" value="${2}"/>
<fmt:parseNumber var="result" value="${(currentPage-1)/pageBlock}" integerOnly="true"/>
<c:set var="startPage" value="${result*pageBlock+1}"/>
<c:set var="endPage" value="${startPage+pageBlock-1}"/>
<c:if test="${endPage > pageCount}">
<c:set var="endPage" value="${pageCount}"/>
</c:if>
<%-- ${startPage}, ${endPage}--%>
<c:if test="${startPage > pageBlock}">
<a href="${root}/fileBoard/list.do?pageNumber=${startPage-pageBlock}">[μ΄μ ]</a>
</c:if>
<c:forEach var="i" begin="${startPage}" end="${endPage}">
<a href="${root}/fileBoard/list.do?pageNumber=${i}">[${i}]</a>
</c:forEach>
<c:if test="${endPage < pageCount }">
<a href="${root}/fileBoard/list.do?pageNumber=${startPage+pageBlock}">[λ€μ]</a>
</c:if>
</div>
</body>
</html>
read.jsp
<%@ 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>
<c:set var="root" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ μ½κΈ° νμ΄μ§</title>
<link rel="stylesheet" href="${root}/css/board/boardStyle.css" />
<script type="text/javascript">
function boardCheck(obj){
//alert("OK");
}
function replyFunc(root, boardNumber, groupNumber, sequenceNumber, sequenceLevel){
var url = root + "/fileBoard/write.do?boardNumber=" + boardNumber +
"&groupNumber=" + groupNumber + "&sequenceNumber=" + sequenceNumber +
"&sequenceLevel=" + sequenceLevel;
location.href = url;
}
function delFunc(root, boardNumber, pageNumber){
var url = root+ "/fileBoard/delete.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
location.href = url;
/*var value = confirm("μμ νμκ² μ΅λκΉ?");
if(value == true){
var url = root+ "/board/deleteOk.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
alert(url);
}else{
alert("μ·¨μλμμ΅λλ€.");
}*/
}
function updFunc(root, boardNumber, pageNumber){
var url = root + "/fileBoard/update.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
location.href = url;
}
</script>
</head>
<body>
<div id="createform">
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">κΈλ²νΈ</div>
${boardDto.boardNumber}
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μμ±μ</div>
${boardDto.writer}
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μ‘°νμ</div>
${boardDto.readCount}
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μμ±μΌ</div>
<fmt:formatDate value="${boardDto.writeDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μ λͺ©</div>
${boardDto.subject}
</div>
<div class="content" style="border-bottom-width: 0px;">
<div id="text">λ΄μ©</div>
${boardDto.content}
</div>
<c:if test="${boardDto.fileSize!=0}">
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">νμΌλͺ
</div>
<a href="${root}/fileBoard/download.do?boardNumber=${boardDto.boardNumber}">${boardDto.fileName}</a>
</div>
</c:if>
<div class="menu" style="border-bottom-width: 3px; text-align: center;">
<input type="button" value="κΈμμ " onclick="updFunc('${root}','${boardDto.boardNumber}','${pageNumber}')"/>
<input type="button" value="κΈμμ " onclick="delFunc('${root}','${boardDto.boardNumber}','${pageNumber}')"/>
<input type="button" value="λ΅κΈ" onclick="replyFunc('${root}','${boardDto.boardNumber}','${boardDto.groupNumber}','${boardDto.sequenceNumber}','${boardDto.sequenceLevel}')"/>
<input type="button" value="κΈλͺ©λ‘" onclick="location.href='${root}/fileBoard/list.do?pageNumber=${pageNumber}'"/>
</div>
</div>
</body>
</html>
update.jsp
<%@ 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>
<c:set var="root" value="${pageContext.request.contextPath }" />
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ μμ νμ΄μ§</title>
<link rel="stylesheet" href="${root}/css/board/boardStyle.css" />
<script type="text/javascript">
function boardCheck(obj){
//alert("OK");
}
function updFunc(root, boardNumber, pageNumber){
var url = root + "/fileBoard/update.do?boardNumber=" + boardNumber + "&pageNumber=" + pageNumber;
location.href = url;
}
</script>
</head>
<body>
<form id="createform" action="${root}/fileBoard/updateOk.do" method="post" enctype="multipart/form-data">
<div id="title"><a href="${root}/fileBoard/list.do">κΈλͺ©λ‘</a></div>
${boardNumber}
<div class="menu" style="border-bottom-width: 0px;">
<input type="hidden" name="boardNumber" value="${boardDto.boardNumber}"/>
<input type="hidden" name="groupNumber" value="${boardDto.groupNumber}" />
<input type="hidden" name="sequenceNumber" value="${boardDto.sequenceNumber}" />
<input type="hidden" name="sequenceLevel" value="${boardDto.sequenceLevel}" />
<input type="hidden" name="pageNumber" value="${pageNumber}"/>
<div id="id">μμ±μ</div>
<span>
${boardDto.writer}
<input type="hidden" name="writer" value="${boardDto.writer}"/>
</span>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μ λͺ©</div>
<span>
<input type="text" name="subject" size="50" value="${boardDto.subject}"/>
</span>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">μ΄λ©μΌ</div>
<span>
<input type="email" name="email" size="50" value="${boardDto.email}"/>
</span>
</div>
<div class="content" style="border-bottom-width: 0px;">
<div id="text">λ΄μ©</div>
<span>
<textarea name="content" rows="12" cols="65" >${boardDto.content}</textarea>
</span>
</div>
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">λΉλ°λ²νΈ</div>
<span>
<input type="password" name="password" size="30" value="${boardDto.password}"/>
</span>
</div>
<!-- νμΌλͺ
-->
<div class="menu" style="border-bottom-width: 0px;">
<div id="id">νμΌλͺ
</div>
<span>
${boardDto.fileName}
<input type="file" name="file" size="50"/>
</span>
</div>
<div class="menu" style="border-bottom-width: 3px; text-align: center;">
<span>
<input type="submit" value="μμ μλ£"/>
<input type="reset" value="λ€μμμ±" />
<input type="button" value="λͺ©λ‘보기" onclick="location.href='${root}/fileBoard/list.do'"/>
</span>
</div>
</form>
</body>
</html>
updateOk.jsp
<%@ 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>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ μμ μλ£νμ΄μ§</title>
</head>
<body>
<c:if test="${check > 0}">
<script type="text/javascript">
alert("μμ λμμ΅λλ€.");
location.href="${root}/fileBoard/list.do?";
</script>
</c:if>
<c:if test="${check == 0}">
<script type="text/javascript">
alert("μμ λμ§ μμμ΅λλ€.");
location.href="${root}/fileBoard/update.do?";
</script>
</c:if>
</body>
</html>
delete.jsp
<%@ 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>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ μμ νμ΄μ§</title>
</head>
<body>
<div align="center">
<form action="${root}/fileBoard/deleteOk.do" method="post">
<input type="hidden" name="boardNumber" value="${boardNumber}"/>
<input type="hidden" name="pageNumber" value="${pageNumber}"/>
<div>λΉλ°λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ.</div>
<div>
<input type="password" name="password"/>
</div>
<div>
<input type="submit" value="κΈμμ "/>
<input type="button" value="λͺ©λ‘보기" onclick="location.href='${root}/fileBoard/list.do?pageNumber=${pageNumber}'"/>
</div>
</form>
</div>
</body>
</html>
deleteOk.jsp
<%@ 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>
<c:set var = "root" value = "${pageContext.request.contextPath}"/>
<html>
<head>
<meta charset="UTF-8">
<title>νμΌλ³΄λ μμ μλ£νμ΄μ§</title>
</head>
<body>
<c:if test="${check > 0}">
<script type="text/javascript">
alert("μμ λμμ΅λλ€.");
location.href="${root}/fileBoard/list.do?pageNumber=${pageNumber}";
</script>
</c:if>
<c:if test="${check == 0}">
<script type="text/javascript">
alert("μμ λμ§ μμμ΅λλ€.");
location.href="${root}/fileBoard/list.do?pageNumber=${pageNumber}";
</script>
</c:if>
</body>
</html>
fileBoard.xml
맀ν μ€μ
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- URL/Function -->
<bean id="propertiesMethodNameResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/fileBoard/write.do">fileBoardWrite</prop>
<prop key="/fileBoard/writeOk.do">fileBoardWriteOk</prop>
<prop key="/fileBoard/list.do">fileBoardList</prop>
<prop key="/fileBoard/read.do">fileBoardRead</prop>
<prop key="/fileBoard/download.do">fileDownLoad</prop>
<prop key="/fileBoard/update.do">fileBoardUpdate</prop>
<prop key="/fileBoard/updateOk.do">fileBoardUpdateOk</prop>
<prop key="/fileBoard/delete.do">fileBoardDelete</prop>
<prop key="/fileBoard/deleteOk.do">fileBoardDeleteOk</prop>
</props>
</property>
</bean>
<!-- FileBoardController -->
<bean id="fileBoardController" class="com.java.fileboard.controller.FileBoardController">
<property name="fileBoardService" ref="fileBoardServiceImp"></property>
<property name="methodNameResolver" ref="propertiesMethodNameResolver"></property>
</bean>
<!-- FileBoardService -->
<bean id="fileBoardServiceImp" class="com.java.fileboard.service.FileBoardServiceImp">
<property name="fileBoardDao" ref="fileBoardDaoImp"></property>
</bean>
<!-- FileBoardDAO -->
<bean id="fileBoardDaoImp" class="com.java.fileboard.dao.FileBoardDaoImp">
<constructor-arg ref="sqlSessionTemplate"></constructor-arg>
</bean>
<!-- FileUpload -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="502400"/> <!-- 102400 -->
<property name="defaultEncoding" value="utf-8"/>
</bean>
</beans>
FileBoardController.java
package com.java.fileboard.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import com.java.fileboard.dto.FileBoardDto;
import com.java.fileboard.service.FileBoardService;
public class FileBoardController extends MultiActionController{
private FileBoardService fileBoardService;
public FileBoardController() {}
public FileBoardController(FileBoardService fileBoardService) {
this.fileBoardService = fileBoardService;
}
public void setFileBoardService(FileBoardService fileBoardService) {
this.fileBoardService = fileBoardService;
}
public ModelAndView fileBoardWrite(HttpServletRequest req, HttpServletResponse res) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
fileBoardService.fileBoardWrite(mav);
return mav;
}
public ModelAndView fileBoardWriteOk(HttpServletRequest req, HttpServletResponse res, FileBoardDto fileBoardDto) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
mav.addObject("fileBoardDto", fileBoardDto);
fileBoardService.fileBoardWriteOk(mav);
return mav;
}
public ModelAndView fileBoardList(HttpServletRequest request, HttpServletResponse response) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", request);
fileBoardService.fileBoardList(mav);
return mav;
}
public ModelAndView fileBoardRead(HttpServletRequest req, HttpServletResponse res) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
fileBoardService.fileBoardRead(mav);
return mav;
}
public void fileDownLoad(HttpServletRequest req, HttpServletResponse res) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
mav.addObject("response", res);
fileBoardService.fileDownLoad(mav);
}
public ModelAndView fileBoardUpdate(HttpServletRequest req, HttpServletResponse res) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
fileBoardService.fileBoardUpdate(mav);
return mav;
}
public ModelAndView fileBoardUpdateOk(HttpServletRequest req, HttpServletResponse res, FileBoardDto fileBoardDto) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
mav.addObject("fileBoardDto", fileBoardDto);
fileBoardService.fileBoardUpdateOk(mav);
return mav;
}
public ModelAndView fileBoardDelete(HttpServletRequest req, HttpServletResponse res) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
fileBoardService.fileBoardDelete(mav);
return mav;
}
public ModelAndView fileBoardDeleteOk(HttpServletRequest req, HttpServletResponse res) {
ModelAndView mav = new ModelAndView();
mav.addObject("request", req);
fileBoardService.fileBoardDeleteOk(mav);
return mav;
}
}
FileBoardService.java
package com.java.fileboard.service;
import org.springframework.web.servlet.ModelAndView;
public interface FileBoardService {
public void fileBoardWrite(ModelAndView mav);
public void fileBoardWriteOk(ModelAndView mav);
public void fileBoardList(ModelAndView mav);
public void fileBoardRead(ModelAndView mav);
public void fileDownLoad(ModelAndView mav);
public void fileBoardUpdate(ModelAndView mav);
public void fileBoardUpdateOk(ModelAndView mav);
public void fileBoardDelete(ModelAndView mav);
public void fileBoardDeleteOk(ModelAndView mav);
}
FileBoardServiceImp.java
fileBoardWrite, fileBoardWriteOk, writeNumber, fileBoardList, fileBoardRead, fileDownLoad, fileBoardUpdate, fileBoardUpdateOk, fileBoardDelete, fileBoardDeleteOk ν¨μ μμ±
package com.java.fileboard.service;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.java.aop.HAspect;
import com.java.fileboard.dao.FileBoardDao;
import com.java.fileboard.dto.FileBoardDto;
public class FileBoardServiceImp implements FileBoardService{
private FileBoardDao fileBoardDao;
public FileBoardServiceImp() { }
public FileBoardServiceImp(FileBoardDao fileBoardDao) {
this.fileBoardDao = fileBoardDao;
}
public void setFileBoardDao(FileBoardDao fileBoardDao) {
this.fileBoardDao = fileBoardDao;
}
@Override
public void fileBoardWrite(ModelAndView mav) {
//λΆλͺ¨κΈ(ROOT)
int boardNumber = 0; //ROOTκΈμ΄λ©΄ 0
int groupNumber = 1; //κ·Έλ£Ήλ²νΈ
int sequenceNumber = 0; //κΈμμ
int sequenceLevel = 0; //κΈλ 벨
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest)map.get("request");
//λ΅κΈμΈκ²½μ° λΆλͺ¨κΈμ DB κΈλ²νΈ, κ·Έλ£Ήλ²νΈ, κΈμμ, κΈλ 벨
if(request.getParameter("boardNumber")!=null) {
boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
groupNumber = Integer.parseInt(request.getParameter("groupNumber"));
sequenceNumber = Integer.parseInt(request.getParameter("sequenceNumber"));
sequenceLevel = Integer.parseInt(request.getParameter("sequenceLevel"));
}
mav.addObject("boardNumber", boardNumber);
mav.addObject("groupNumber", groupNumber);
mav.addObject("sequenceNumber", sequenceNumber);
mav.addObject("sequenceLevel", sequenceLevel);
mav.setViewName("fileBoard/write");
}
@Override
public void fileBoardWriteOk(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
FileBoardDto fileBoardDto = (FileBoardDto) map.get("fileBoardDto");
MultipartHttpServletRequest request = (MultipartHttpServletRequest)map.get("request");
writeNumber(fileBoardDto);
fileBoardDto.setWriteDate(new Date());
fileBoardDto.setReadCount(0);
MultipartFile upFile = request.getFile("file");
HAspect.logger.info(HAspect.logMsg + fileBoardDto);
if(upFile!=null) {
//μ μ₯κ²½λ‘, νμΌλͺ
, μ¬μ΄μ¦
String fileName = Long.toString(System.currentTimeMillis())+ "_" + upFile.getOriginalFilename();
long fileSize = upFile.getSize();
File path = new File("C:\\pds\\");
path.mkdir();
if(path.exists() && path.isDirectory()) {
File file = new File(path, fileName);
try {
upFile.transferTo(file);
fileBoardDto.setPath(file.getAbsolutePath());
fileBoardDto.setFileName(fileName);
fileBoardDto.setFileSize(fileSize);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
HAspect.logger.info(HAspect.logMsg +fileBoardDto);
int check = fileBoardDao.fileBoardWrite(fileBoardDto);
HAspect.logger.info(HAspect.logMsg + check);
mav.addObject("check", check);
mav.setViewName("fileBoard/writeOk");
}
public void writeNumber(FileBoardDto boardDto) {
// κ·Έλ£Ήλ²νΈ(ROOT), κΈμμ(μμ), κΈλ 벨(μμ)
int boardNumber = boardDto.getBoardNumber(); // 0
int groupNumber = boardDto.getGroupNumber(); // 1
int sequenceNumber = boardDto.getSequenceNumber(); // 0
int sequenceLevel = boardDto.getSequenceLevel(); // 0
if (boardNumber == 0) { // ROOT : κ·Έλ£Ήλ²νΈ
int max = fileBoardDao.fileBoardGroupNumberMax();
if (max != 0)
boardDto.setGroupNumber(max + 1);
} else { // λ΅κΈ : κΈ μμ, κΈ λ 벨
HashMap<String, Integer> hMap = new HashMap<String, Integer>();
hMap.put("groupNumber", groupNumber);
hMap.put("sequenceNumber", sequenceNumber);
int check = fileBoardDao.fileBoardWriteNumber(hMap);
sequenceNumber = sequenceNumber + 1;
sequenceLevel = sequenceLevel + 1;
boardDto.setSequenceNumber(sequenceNumber);
boardDto.setSequenceLevel(sequenceLevel);
}
}
@Override
public void fileBoardList(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest) map.get("request");
String pageNumber = request.getParameter("pageNumber");
if (pageNumber == null)
pageNumber = "1";
int currentPage = Integer.parseInt(pageNumber); // μμ² 1page
//HAspect.logger.info(HAspect.logMsg + "currentPage" + currentPage);
int boardSize = 5; // viewμ λͺκ°μ κΈμ 보μ¬μ€μ§
int startRow = (currentPage - 1) * boardSize + 1; // μμλ²νΈ 1 11
int endRow = currentPage * boardSize; // λλ²νΈ 10 20
//HAspect.logger.info(HAspect.logMsg + "startRow:" +startRow + "\t" + "endRow:" +endRow);
int count = fileBoardDao.fileBoardCount();
HAspect.logger.info(HAspect.logMsg + count);
List<FileBoardDto> boardList = null;
if (count > 0) {
// startRow, endRow
boardList = fileBoardDao.fileBoardList(startRow, endRow);
HAspect.logger.info(HAspect.logMsg + boardList.size());
}
mav.addObject("boardList", boardList);
mav.addObject("boardSize", boardSize);
mav.addObject("currentPage", currentPage);
mav.addObject("count", count);
mav.setViewName("fileBoard/list");
}
@Override
public void fileBoardRead(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest)map.get("request");
int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
HAspect.logger.info(HAspect.logMsg + boardNumber + "\t" + pageNumber);
FileBoardDto fileBoardDto = fileBoardDao.fileBoardRead(boardNumber);
HAspect.logger.info(HAspect.logMsg + fileBoardDto);
if(fileBoardDto.getFileName()!=null) {
int index = fileBoardDto.getFileName().indexOf("-")+1;
fileBoardDto.setFileName(fileBoardDto.getFileName().substring(index));
}
mav.addObject("boardDto", fileBoardDto);
mav.addObject("pageNumber", pageNumber);
mav.setViewName("fileBoard/read");
}
@Override
public void fileDownLoad(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest)map.get("request");
HttpServletResponse response = (HttpServletResponse)map.get("response");
int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
HAspect.logger.info(HAspect.logMsg + boardNumber);
FileBoardDto boardDto = fileBoardDao.fileBoardSelect(boardNumber);
HAspect.logger.info(HAspect.logMsg + boardDto);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
int index = boardDto.getFileName().indexOf("_") + 1;
String fName = boardDto.getFileName().substring(index);
String fileName = new String(fName.getBytes("utf-8"), "ISO-8859-1");
long fileSize = boardDto.getFileSize();
String path = boardDto.getPath();
// μΈν
μ΄ νμ
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.setContentType("application/octet-stream");
response.setContentLengthLong(fileSize);
bis = new BufferedInputStream(new FileInputStream(path), 1024);
bos = new BufferedOutputStream(response.getOutputStream(), 1024);
while(true) {
int data = bis.read();
if(data == -1) break;
bos.write(data);
}
bos.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(bis!=null) bis.close();
if(bos!=null) bos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void fileBoardUpdate(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest)map.get("request");
int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
HAspect.logger.info(HAspect.logMsg + boardNumber + "\t" + pageNumber);
FileBoardDto fileBoardDto = fileBoardDao.fileBoardUpdate(boardNumber);
HAspect.logger.info(HAspect.logMsg + fileBoardDto);
if(fileBoardDto.getFileName()!=null) {
int index = fileBoardDto.getFileName().indexOf("-")+1;
fileBoardDto.setFileName(fileBoardDto.getFileName().substring(index));
}
mav.addObject("boardDto", fileBoardDto);
mav.setViewName("fileBoard/update");
}
@Override
public void fileBoardUpdateOk(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
MultipartHttpServletRequest request = (MultipartHttpServletRequest)map.get("request");
FileBoardDto fileBoardDto = (FileBoardDto) map.get("fileBoardDto");
writeNumber(fileBoardDto);
fileBoardDto.setWriteDate(new Date());
fileBoardDto.setReadCount(0);
MultipartFile upFile = request.getFile("file");
HAspect.logger.info(HAspect.logMsg + upFile.getOriginalFilename());
if(upFile.getSize()!=0) {
//μ μ₯κ²½λ‘, νμΌλͺ
, μ¬μ΄μ¦
String fileName = Long.toString(System.currentTimeMillis())+ "_" + upFile.getOriginalFilename();
long fileSize = upFile.getSize();
File path = new File("C:\\pds\\");
path.mkdir();
if(path.exists() && path.isDirectory()) {
File file = new File(path, fileName);
try {
upFile.transferTo(file);
fileBoardDto.setPath(file.getAbsolutePath());
fileBoardDto.setFileName(fileName);
fileBoardDto.setFileSize(fileSize);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
HAspect.logger.info(HAspect.logMsg +fileBoardDto);
int check = fileBoardDao.fileBoardUpdateOk(fileBoardDto);
HAspect.logger.info(HAspect.logMsg + check);
mav.addObject("check", check);
mav.setViewName("fileBoard/updateOk");
}
@Override
public void fileBoardDelete(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest)map.get("request");
int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
HAspect.logger.info(HAspect.logMsg + boardNumber + pageNumber);
mav.addObject("boardNumber", boardNumber);
mav.addObject("pageNumber", pageNumber);
mav.setViewName("fileBoard/delete");
}
@Override
public void fileBoardDeleteOk(ModelAndView mav) {
Map<String, Object> map = mav.getModelMap();
HttpServletRequest request = (HttpServletRequest)map.get("request");
int boardNumber = Integer.parseInt(request.getParameter("boardNumber"));
int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
String password = request.getParameter("password");
HAspect.logger.info(HAspect.logMsg + boardNumber +"t"+ pageNumber +"t"+ password);
int check = fileBoardDao.fileBoardDelete(boardNumber, password);
HAspect.logger.info(HAspect.logMsg + check);
mav.addObject("check", check);
mav.addObject("pageNumber", pageNumber);
mav.setViewName("fileBoard/deleteOk");
}
}
[interface] FileBoardDao.java
fileBoardGroupNumberMax, fileBoardWriteNumber, fileBoardWrite, fileBoardCount, fileBoardList, fileBoardRead, fileBoardSelect, fileBoardUpdate, fileBoardUpdateOk, fileBoardDelete ν¨μ μΆκ°
package com.java.fileboard.dao;
import java.util.HashMap;
import java.util.List;
import com.java.fileboard.dto.FileBoardDto;
public interface FileBoardDao {
public int fileBoardGroupNumberMax();
public int fileBoardWriteNumber(HashMap<String, Integer> hMap);
public int fileBoardWrite(FileBoardDto fileBoardDto);
public int fileBoardCount();
public List<FileBoardDto> fileBoardList(int startRow, int endRow);
public FileBoardDto fileBoardRead(int boardNumber);
public FileBoardDto fileBoardSelect(int boardNumber);
public FileBoardDto fileBoardUpdate(int boardNumber);
public int fileBoardUpdateOk(FileBoardDto fileBoardDto);
public int fileBoardDelete(int boardNumber, String password);
}
FileBoardMapper.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="dao.mapper.FileBoardMapper">
<resultMap type="com.java.fileboard.dto.FileBoardDto" id="fileBoardDto">
<!-- column: λ°μ΄ν°λ² μ΄μ€ property : data -->
<result column="board_number" property="boardNumber" />
<result column="writer" property="writer" />
<result column="subject" property="subject" />
<result column="email" property="email" />
<result column="content" property="content" />
<result column="password" property="password" />
<result column="write_date" property="writeDate" />
<result column="read_count" property="readCount" />
<result column="group_number" property="groupNumber" />
<result column="sequence_number" property="sequenceNumber" />
<result column="sequence_level" property="sequenceLevel" />
<result column="file_name" property="fileName" />
<result column="path" property="path" />
<result column="file_size" property="fileSize" />
</resultMap>
<select id="board_group_number_max" resultType="int">
select nvl(max(group_number), 0) from board
</select>
<update id="board_writer_number" parameterType="java.util.HashMap">
update board set sequence_number=sequence_number+1
where group_number=#{groupNumber} and sequence_number>#{sequenceNumber}
</update>
<insert id="board_insert" parameterType="com.java.fileboard.dto.FileBoardDto">
insert into board(
board_number,
writer,
subject,
email,
content,
password,
write_date,
read_count,
group_number,
sequence_number,
sequence_level,
file_name,
path,
file_size)
values (board_number_seq.nextval,
#{writer},
#{subject},
#{email},
#{content},
#{password},
#{writeDate},
#{readCount},
#{groupNumber},
#{sequenceNumber},
#{sequenceLevel},
#{fileName},
#{path},
#{fileSize})
</insert>
<select id="board_count" resultType="int">
select count(*) from board
</select>
<select id="board_list" parameterType="java.util.Map" resultMap="fileBoardDto">
<![CDATA[
select * from
(select rownum as rnum, a.* from
(select * from board order by group_number desc, sequence_number asc) a) b
where b.rnum>=#{startRow} and b.rnum<=#{endRow}
]]>
</select>
<update id="board_read_count" parameterType="int">
<![CDATA[
update board set read_count=read_count+1 where board_number =#{boardNumber}
]]>
</update>
<select id="board_read" parameterType="int" resultMap="fileBoardDto">
select * from board where board_number=#{boardNumber}
</select>
<delete id="board_delete" parameterType="java.util.HashMap" >
delete from board where board_number=#{boardNumber} and password=#{password}
</delete>
<update id="board_update" parameterType="java.util.HashMap">
update board set subject=#{boardDto.subject}, email=#{boardDto.email}, content=#{boardDto.content}, password=#{boardDto.password}, write_date=#{boardDto.writeDate} where board_number=#{boardNumber}
</update>
</mapper>
FileBoardDaoImp.java
package com.java.fileboard.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.mybatis.spring.SqlSessionTemplate;
import com.java.fileboard.dto.FileBoardDto;
public class FileBoardDaoImp implements FileBoardDao{
private SqlSessionTemplate sqlSessionTemplate;
public FileBoardDaoImp() { }
public FileBoardDaoImp(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSessionTemplate = sqlSessionTemplate;
}
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSessionTemplate = sqlSessionTemplate;
}
@Override
public int fileBoardGroupNumberMax() {
return sqlSessionTemplate.selectOne("board_group_number_max");
}
@Override
public int fileBoardWriteNumber(HashMap<String, Integer> hMap) {
return sqlSessionTemplate.update("board_writer_number", hMap);
}
@Override
public int fileBoardWrite(FileBoardDto fileBoardDto) {
return sqlSessionTemplate.insert("board_insert", fileBoardDto);
}
@Override
public int fileBoardCount() {
return sqlSessionTemplate.selectOne("board_count");
}
@Override
public List<FileBoardDto> fileBoardList(int startRow, int endRow) {
Map<String, Integer> hMap = new HashMap<String, Integer>();
hMap.put("startRow", startRow);
hMap.put("endRow", endRow);
return sqlSessionTemplate.selectList("board_list", hMap);
}
@Override
public FileBoardDto fileBoardRead(int boardNumber) {
sqlSessionTemplate.update("board_read_count", boardNumber);
return sqlSessionTemplate.selectOne("board_read", boardNumber);
}
@Override
public FileBoardDto fileBoardSelect(int boardNumber) {
return sqlSessionTemplate.selectOne("board_read", boardNumber);
}
@Override
public FileBoardDto fileBoardUpdate(int boardNumber) {
return sqlSessionTemplate.selectOne("board_read", boardNumber);
}
@Override
public int fileBoardUpdateOk(FileBoardDto fileBoardDto) {
Map<String, Object> hMap = new HashMap<String, Object>();
hMap.put("boardNumber", fileBoardDto.getBoardNumber());
hMap.put("boardDto", fileBoardDto);
return sqlSessionTemplate.update("board_update", hMap);
}
@Override
public int fileBoardDelete(int boardNumber, String password) {
Map<String, Object> hMap = new HashMap<String, Object>();
hMap.put("boardNumber", boardNumber);
hMap.put("password", password);
return sqlSessionTemplate.update("board_delete", hMap);
}
}
myBatis.xml
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- Spring DB -->
<bean id="driverManagerDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
<property name="username" value="mvc"/>
<property name="password" value="1234"/>
</bean>
<!-- MyBatis : sqlSessionFactoryBean -->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="driverManagerDataSource"/>
<property name="mapperLocations">
<list>
<value>classpath:com/java/member/dao/mapper/MemberMapper.xml</value>
<value>classpath:com/java/fileboard/dao/mapper/FileBoardMapper.xml</value>
</list>
</property>
</bean>
<!-- MyBatis : sqlSessionTemplate -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactoryBean"/>
</bean>
<!-- Transaction 곡ν΅ν΄λμ€ -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="driverManagerDataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
<!-- propagation="REQUIRED" : μ΄λ―Έ νλμ νΈλμμ
μ΄ μ‘΄μ¬νλ©΄ μ§μνκ³ μλ€λ©΄ μλ‘μ§μ -->
<!-- Transaction AOP -->
<aop:config>
<aop:pointcut expression="within(com.java..*)" id="txPublic"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPublic"/>
</aop:config>
</beans>