๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT/WEB

[39์ผ์ฐจ] ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ (2)

by GWLEE 2022. 8. 16.

 

๐Ÿš˜2022-08-16๐Ÿš˜

 

 

 

 

 

connect ํ•˜๋ฉด ๋”ฑ connect.

disconnect ๋ฌผ๊ณ  ์žˆ์œผ๋ฉด ์•ˆ๋จ,, ๋™์‹œ์— ์ ์šฉํ•  ์ˆ˜ ์žˆ๋Š” connection์ด ์œ ํ•œํ•˜๊ธฐ ๋•Œ๋ฌธ์—

๊ณจ๊ณ ๋ฃจ ๋‚˜๋ˆ ์“ฐ๋ ค๋ฉด ๋Š์–ด์„œ ์‚ฌ์šฉ..

๋™์‹œ์— 10๋ช…์€ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํด๋ผ์ด์–ธํŠธ ๋™์‹œ์— ์ ์šฉ

์“ธ ๋•Œ๋งŒ ์—ฐ๊ฒฐํ•˜๊ณ  ํ๊ธฐํ•˜๋Š”..

์ง„์งœ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋‹ค์ˆ˜์ผ ๋•Œ 10๊ฐœ์˜ connection์„ ๋ฏธ๋ฆฌ ๋งŒ๋“ค์–ด ๋‘๊ณ  mysql์ด๋ž‘ ๋ถ™์–ด์žˆ์Œ

์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๊ฐ€์ ธ๋‹ค๊ฐ€ DB์—ฐ๊ฒฐํ•ด์„œ ์“ฐ๊ณ  ๋Š๊ณ ,, ๋ฐ˜๋ณต

connection pool ์ตœ๋Œ€ ํ—ˆ์šฉ ์ปจ๋„ฅ์…˜์„ ๋ฏธ๋ฆฌ ๋งŒ๋“ค์–ด ๋‘”๋‹ค.

2~4๊ฐœ๋งŒ ๋งŒ๋“ค์–ด ๋‘”๋‹ค. ์ข€ ๋” ํ•„์š”ํ•˜๋ฉด +2 +2 +2 .. max.. ์ด๋ฏธ ๋งŒ๋“ค์–ด๋‘”๊ฑฐ๋Š” ์ง€์šฐ์ง€ ์•Š์Œ

๋‹ค๋ฅธ ์„œ๋น„์Šค๋ฅผ ๋งŒ๋“ค์–ด ๋‘์ง€ ์•Š๋Š”๋‹ค. ๋Œ€ํ‘œ์ ์œผ๋กœ ์ปจ๋„ฅ์…˜ ํ’€์„ ์‚ฌ์šฉํ•œ๋‹ค.

 

https://linked2ev.github.io/spring/2019/08/14/Spring-3-%EC%BB%A4%EB%84%A5%EC%85%98-%ED%92%80%EC%9D%B4%EB%9E%80/

 

[Spring] ์ปค๋„ฅ์…˜ ํ’€(Connection pool)์ด๋ž€?

์ปค๋„ฅ์…˜ ํ’€(Connection pool)์— ๋Œ€ํ•ด์„œ ๊ทธ๋ž˜๋„ ์•Œ๊ณ  ์‚ฌ์šฉํ•˜์ž. ์‰ฝ๊ฒŒ ์•Œ๊ณ  ๊ฐ”์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

linked2ev.github.io

 

 

์ „์ฒด๊ฐ€ model ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์— ๋“ค์–ด๊ฐ€๋Š” ๊ฒƒ

๋ชจ๋ธ ๋ถ€๋ถ„์— ํ•˜๋‚˜์˜ ํŒจํ‚ค์ง€

 

controller์—์„œ service service์—์„œ dao๋ถ€๋ฅด๊ธฐ

์ปจํŠธ๋กค๋Ÿฌ์—์„œ dao ์ง์ ‘ ๋ถˆ๋Ÿฌ๋„ ๋˜๋‚˜,,? ๊ตณ์ด ์„œ๋น„์Šค๋ฅผ ๋ผ๋Š” ์ด์œ 

/

1. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ฟผ๋ฆฌ๋ฅผ ๋ฐ”๊พผ๋‹ค. X ํ•œ์‹œ์ ์œผ๋กœ ์“ฐ๋Š” ๊ฑฐ๋ผ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค.

๋‹ค๋ฅธ ๊ณณ์—์„œ ์“ฐ์ผ ์ˆ˜๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—

2. ๊ฐ–๊ณ ์˜ค๋Š” ๋ฉ”์†Œ๋“œ X ์ง์ ‘ ์ ‘๊ทผํ•˜๋‹ˆ๊น MVC๊ฐ€ ๊นจ์ ธ๋ฒ„๋ฆฐ๋‹ค. 

MVC์œ ์ง€๋ณด์ˆ˜... MVC ๋งž๊ฒŒ ์‚ฌ์šฉ

์ค‘๊ฐ„์— ์„œ๋น„์Šค๋ฅผ ๋งŒ๋“ค์—ˆ์œผ๋ฉด, ๋ฆฌํ„ด์—์„œ x0.9๋ฅผ ํ•ด์ฃผ๋ฉด๋œ๋‹ค.

๋น„์ฆˆ๋‹ˆ์Šค๋กœ์ง์ด ์ปจํŠธ๋กค๋Ÿฌ๋กœ ๋ชป๋„˜์–ด๊ฐ€๊ฒŒ...

 

๋…นํ™”_2022_08_16_17_23_32_797.mp4
3.91MB

 


 

config

ControllerConfig.java

package com.gyuone.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.gyuone.controller.BoardController;
import com.gyuone.dao.BoardDao;
import com.gyuone.model.ArticleVO;
import com.gyuone.service.BoardService;

@Configuration
@ComponentScan(basePackages= {"com.gyuone.config, com.gyuone.service"})
public class ControllerConfig {
	@Bean
	public ArticleVO articleVO() {
		return new ArticleVO();
	}

	@Bean
	public BoardDao boardDao() {
		return new BoardDao();
	}

//	@Bean
//	public BoardService boardService() {
//		return new BoardService();
//	}
	
	@Bean
	public BoardController boardController() {
		return new BoardController();
	}
}

 

 

MvcConfig.java

package com.gyuone.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer{

	@Override
	public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
		// TODO Auto-generated method stub
		configurer.enable();
	}

	@Override
	public void configureViewResolvers(ViewResolverRegistry registry) {
		// TODO Auto-generated method stub
		registry.jsp("/WEB-INF/view/", ".jsp"); // .jsp๋ฅผ ์•Œ์•„์„œ ๋ถ™์—ฌ๋ผ.
	}
	
	
}

 

controller

BoardController.java

package com.gyuone.controller;

import java.util.ArrayList;
import java.util.List;

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.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.gyuone.model.ArticleVO;
import com.gyuone.service.BoardService;

@Controller
@RequestMapping("/board") // board๋ฅผ ๋‹ค ๋ฐ›์Œ
public class BoardController {
	@Autowired
	BoardService boardService;
	@Autowired
	ArticleVO articleVo;
	
	List<ArticleVO> articleList = new ArrayList<ArticleVO>();
	
	@RequestMapping({"/listArticles","/"}) // ๋ฐฐ์—ด๋กœ ๋•Œ๋ฆผ
	public String getArticleList(Model model) {
		articleList = boardService.listArticles();
		model.addAttribute("articleList", articleList);
		return "listArticles";
	}
	
	@RequestMapping("/newArticle")
	public String writeArticle(Model model) {
		return "articleForm";
		
	}
	
	@RequestMapping(value="/addArticle", method=RequestMethod.POST)
	public String addArticle(Model model, @RequestParam(value="title") String title,
			@RequestParam(value="content") String content) {
		articleVo.setTitle(title);
		articleVo.setContents(content);
		articleVo.setWriteId("bit");
		boardService.addArticle(articleVo);
		
		return "redirect:listArticles"; // client ---> server addArticle๋กœ ๋“ค์–ด์˜จ๊ฑฐ.
		// server----> client ์š”์ฒญํ•œ๊ฑฐ ๋‹ค ๋๋ƒˆ์œผ๋‹ˆ๊น listArticles๋กœ ๋” ๋ถˆ๋Ÿฌ์ค„๋ž˜? ---> listArticles๋กœ ๋‹ค์‹œ ๋ถˆ๋Ÿฌ์คŒ.
	}
	
	@RequestMapping(value="/viewArticle", method=RequestMethod.GET)
	public ModelAndView viewArticle(@RequestParam(value="articleno") String articleNo) {
		articleVo = boardService.viewArticle(Integer.parseInt(articleNo));
		ModelAndView mv = new ModelAndView();
		mv.setViewName("viewArticle");
		mv.addObject("article", articleVo);
		
		return mv;
	}
}

 

 

dao 

BoardDao.java

package com.gyuone.dao;

import java.io.Reader;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.gyuone.model.ArticleVO;

public class BoardDao {
	private static SqlSessionFactory sessionFactory = null;
	
	public static SqlSessionFactory getInstance() {
		if(sessionFactory == null) {
			try {
				String resource = "mybatis-config.xml";
				Reader reader = Resources.getResourceAsReader(resource);
				sessionFactory = new SqlSessionFactoryBuilder().build(reader);
				reader.close();
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return sessionFactory;
	}

	public List<ArticleVO> selectAllArticles() {
		sessionFactory = getInstance();
		SqlSession session = sessionFactory.openSession();
		List<ArticleVO> articleList = session.selectList("mapper.article.selectAllArticles"); // ๋ฆฌ์ŠคํŠธ ํƒ€์ž…์œผ๋กœ ๋˜์ ธ์ค€๋‹ค.
		session.close();
		return articleList;
	}
	
	public void insertNewArticle(ArticleVO article) {
		sessionFactory = getInstance();
		SqlSession session = sessionFactory.openSession();
		session.insert("mapper.article.insertArticle", article);
		session.commit();
//		session.close(); commit์„ ๋•Œ๋ฆฌ๋ฉด ์•Œ์•„์„œ ํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— close ์•ˆํ•ด๋„ ๋œ๋‹ค.
	}
	
	public ArticleVO selectArticle(int articleNo) {
		sessionFactory = getInstance();
		SqlSession session = sessionFactory.openSession();
		ArticleVO article;
		article = session.selectOne("mapper.article.selectArticle", articleNo);
		session.close();
		return article;
	}
	
	public void updateArticle(ArticleVO article) {
		sessionFactory = getInstance();
		SqlSession session = sessionFactory.openSession();
		session.update("mapper.article.updateArticle", article);
		session.commit();
	}
	
	public void deleteArticle(int articleNo) {
		sessionFactory = getInstance();
		SqlSession session = sessionFactory.openSession();
		session.delete("mapper.article.deleteArticle", articleNo);
		session.commit();
	}
	
	
}

 

model

ArticleVO.java

package com.gyuone.model;

public class ArticleVO {
	private int articleNo;
	private String title;
	private String contents;
	private String writeId;
	private String writeDate;
	
	public ArticleVO() { // value object 
		
	}

	public ArticleVO(int articleNo, String title, String contents, String writeID) {
		super();
		this.articleNo = articleNo;
		this.title = title;
		this.contents = contents;
		this.writeId = writeID; // date๋Š” default๋ผ ๋บ€๋‹ค.
	}

	public int getArticleNo() {
		return articleNo;
	}

	public void setArticleNo(int articleNo) {
		this.articleNo = articleNo;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContents() {
		return contents;
	}

	public void setContents(String contents) {
		this.contents = contents;
	}

	public String getWriteId() {
		return writeId;
	}

	public void setWriteId(String writeId) {
		this.writeId = writeId;
	}

	public String getWriteDate() {
		return writeDate;
	}

	public void setWriteDate(String writeDate) {
		this.writeDate = writeDate;
	}
	
	
}

 

 

service

BoardService.java

package com.gyuone.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gyuone.dao.BoardDao;
import com.gyuone.model.ArticleVO;

@Service
public class BoardService {
	@Autowired
	BoardDao boardDao;
	
	public List<ArticleVO> listArticles(){
		List<ArticleVO> articleList = boardDao.selectAllArticles();
		return articleList;
	}
	
	public void addArticle(ArticleVO article) {
		boardDao.insertNewArticle(article);
	}
	
	public ArticleVO viewArticle(int articleNo) {
		ArticleVO article;
		article = boardDao.selectArticle(articleNo);
		return article;
	}
}

 

src/resources

article-mapper.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="mapper.article">
	<resultMap id="articleResult" type="articleVO">
		<result property="articleNo" column="ArticleNO" />
		<result property="title" column="Title" />
		<result property="contents" column="Contents" />
		<result property="writeDate" column="WriteDate" />
		<result property="writeId" column="WriteID" />
	</resultMap>
	<select id="selectAllArticles" resultMap="articleResult">
		<![CDATA[
			select * from noticeboard order by WriteDate desc
		]]>
	</select>
	<select id="selectArticle" resultType="articleVO"
		parameterType="int">
		<![CDATA[
			select * from noticeboard where ArticleNo = #{articleNo}
		]]>
	</select>
	<insert id="insertArticle" parameterType="articleVO">
		<![CDATA[
			insert into noticeboard (Title, Contents, writeDate, WriteID)
			values (#{title}, #{contents}, default, #{writeId})
		]]>
	</insert>
	<update id="updateArticle" parameterType="articleVO">
		<![CDATA[	
			update noticeboard set Title= #{title}, Contents=#{contents}
			where ArticleNo=#{articleNo}
		]]>
	</update>
	<delete id="deleteArticle" parameterType="articleVO">
		<![CDATA[	
			delete from noticeboard where ArticleNo=#{articleNo}
		]]>
	</delete>
</mapper>

 

mybatis-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
	<typeAliases>
		<typeAlias type="com.gyuone.model.ArticleVO"
			alias="articleVO" />
	</typeAliases>
	<environments default="dev">
		<environment id="dev">
			<transactionManager type="JDBC"></transactionManager>
			<dataSource type="POOLED">
				<property name="driver" value="com.mysql.cj.jdbc.Driver" />
				<property name="url"
					value="jdbc:mysql://localhost:3306/board?useUnicode=true&amp;characterEncoding=utf8" />
				<property name="username" value="gyuwon" />
				<property name="password" value="1234" />
			</dataSource>
		</environment>
	</environments>
	<mappers>
		<mapper resource="article-mapper.xml" />
	</mappers>
</configuration>

src

โ””main

โ””webapp

   โ””WEB-INF

   โ””view

      โ””articleForm.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<%
	request.setCharacterEncoding("UTF-8"); // ์ž๋ฐ” ์†Œ์Šค ์ฝ”๋“œ์‚ฌ์šฉ
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>๊ธ€์“ฐ๊ธฐ</title>
<script>
	function backToList(frm) {
		frm.action="${contextPath}/board/listArticles";
		frm.submit();
	}
</script>
<style>
.class-caption {
	width: 100px;
}

.class-content {
	width: 500px;
}

@font-face {
	font-family: 'LeeSeoyun';
	src:
		url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2202-2@1.0/LeeSeoyun.woff')
		format('woff');
	font-weight: normal;
	font-style: normal;
}

* {
	font-family: 'LeeSeoyun';
}

input:focus { background-color: #c0d9fc; }
textarea:focus { background-color: #c0d9fc; }


</style>
</head>
<body>
	<h1 style="text-align: center; color:#c0d9fc;">์ƒˆ ๊ธ€ ์“ฐ๊ธฐ</h1>
	<form name="articleForm" method="post" action="${contextPath}/board/addArticle">
		<table boarder="0" align="center">
			<tbody>
				<tr>
					<td align="right" class="class-caption">๊ธ€์ œ๋ชฉ:</td>
					<td colspan="2">
						<input type="text" maxlength="100" name="title" class="class-content" />
					</td>
				</tr>
				<tr>
					<td align="right" valign="top" class="class-caption"><br>๊ธ€๋‚ด์šฉ:</td>
					<td colspan="2">
						<textarea name="content" rows="10" maxlength="2000" class="class-content" ></textarea>
					</td>
				</tr>
				<tr>
					<td align="right"></td>
					<td colspan="2">
						<input type="submit" value="๊ธ€์“ฐ๊ธฐ" />
						<input type="button" value="๋ชฉ๋ก๋ณด๊ธฐ" onclick = "backToList(articleForm)" />
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</body>
</html>

 

      โ””listArticles.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<%
request.setCharacterEncoding("UTF-8"); // ์ž๋ฐ” ์†Œ์Šค ์ฝ”๋“œ์‚ฌ์šฉ
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>๊ธ€ ๋ชฉ๋ก</title>
<style>
@font-face {
	font-family: 'LeeSeoyun';
	src:
		url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2202-2@1.0/LeeSeoyun.woff')
		format('woff');
	font-weight: normal;
	font-style: normal;
}

* {
	font-family: 'LeeSeoyun';
}

.cls1 {
	text-decoration: none;
}

.cls2 {
	text-align: center;
	font-size: 30px;
	display: block;
}

a:hover {
	color: #153acf;
}

button:hover{
	background-color: #c0d9fc;
}

/* width */
::-webkit-scrollbar {
	width: 25px;
}

/* Track */
::-webkit-scrollbar-track {
	box-shadow: inset 0 0 3px #c0d9fc;
	border-radius: 5px;
}

/* Handle */
::-webkit-scrollbar-thumb {
	background: #c0d9fc;;
	border-radius: 5px;
}
</style>
</head>
<body>
	<h1 style="text-align: center; color: #c0d9fc;">๊ธ€ ๋ชฉ๋ก</h1>
	<br><br>
	<table align="center" border="1" width="80%">
		<thead>
			<tr height="10" align="center" bgcolor="#c0d9fc">
				<th>๊ธ€ ๋ฒˆํ˜ธ</th>
				<th>์ž‘์„ฑ์ž</th>
				<th>์ œ๋ชฉ</th>
				<th>์ž‘์„ฑ์ผ</th>
			</tr>
		</thead>
		<c:choose>
			<c:when test="${articleList == null}">
				<tbody>
					<tr height="10">
						<td colspan="4">
							<p align="center">
								<b><span style="font-size: 9pt;">๋“ฑ๋ก๋œ ๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.</span></b>
							</p>
						</td>
					</tr>
				</tbody>
			</c:when>
			<c:otherwise>
				<!-- core ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ -->
				<tbody>
					<c:forEach var="article" items="${articleList}"
						varStatus="articleNum">
						<tr align="center">
							<td width="5%">${articleNum.count}</td>
							<td width="10%">${article.writeId}</td>
							<td align="left" width="35%"><span
								style="padding-right: 30px"></span> <a class="cls1"
								href="${contextPath}/board/viewArticle?articleno=${article.articleNo}">
									${article.title} </a></td>
							<td width="10%">${article.writeDate}</td>
						</tr>
					</c:forEach>
				</tbody>
			</c:otherwise>
		</c:choose>
	</table>
	<br>
	<a class="cls1" href="${contextPath}/board/newArticle">
		<center>
			<button>
				<span class="clas2">๊ธ€์“ฐ๊ธฐ</span>
			</button>
		</center>
	</a>
</body>
</html>

 

      โ””viewArticle.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<%
	request.setCharacterEncoding("UTF-8"); // ์ž๋ฐ” ์†Œ์Šค ์ฝ”๋“œ์‚ฌ์šฉ
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>๊ธ€๋ณด๊ธฐ</title>
<script>
	function backToList(frm) {
		frm.action="${contextPath}/board/listArticles";
		frm.submit();
  	}
	
	function fn_enable(){
		document.querySelector("#i_title").disabled = false;
		document.querySelector("#i_content").disabled = false;
		document.querySelector("#tr_btn_modify").style.display = "table-row";
		document.querySelector("#tr_btn").style.display = "none";
	}
  
  
</script>
<style>
#tr_btn_modify {
	display: none;
}

@font-face {
	font-family: 'LeeSeoyun';
	src:
		url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2202-2@1.0/LeeSeoyun.woff')
		format('woff');
	font-weight: normal;
	font-style: normal;
}

* {
	font-family: 'LeeSeoyun';
}

		/* width */
		::-webkit-scrollbar {
			width: 25px;
		}

		/* Track */
		::-webkit-scrollbar-track {
			box-shadow: inset 0 0 3px #c0d9fc;
			border-radius: 5px;
		}

		/* Handle */
		::-webkit-scrollbar-thumb {
			background: #c0d9fc;
			;
			border-radius: 5px;
		}
		
</style>
</head>
<body>
	<h1 style="text-align: center; color: #c0d9fc;">์ž‘์„ฑํ•œ ๊ธ€ ํ™•์ธ</h1>
	<br>
	<form name="frmArticle" method="post" action="">
		<table border="0" align="center">
			<tbody>
				<tr>
					<td width="150" align="center" bgcolor="#c0d9fc">๊ธ€๋ฒˆํ˜ธ</td>
					<td><input name="articleNo" type="text"
						value="${article.articleNo}" disabled /></td>
				</tr>
				<tr>
					<td width="150" align="center" bgcolor="#c0d9fc">์ž‘์„ฑ์žID</td>
					<td><input name="writer" type="text"
						value="${article.writeId}" disabled /></td>
				</tr>
				<tr>
					<td width="150" align="center" bgcolor="#c0d9fc">์ œ๋ชฉ</td>
					<td><input name="title" type="text" value="${article.title}"
						id="i_title" disabled /></td>
				</tr>
				<tr>
					<td width="150" align="center" bgcolor="#c0d9fc">๋‚ด์šฉ</td>
					<td><textarea name="content" rows="20" cols="60"
							id="i_content" disabled>${article.contents}</textarea></td>
				</tr>
				<tr>
					<td width="20%" align="center" bgcolor="#c0d9fc">๋“ฑ๋ก์ผ์ž</td>
					<td><input type="text" value="${article.writeDate}" disabled /></td>
				</tr>
				<tr id="tr_btn_modify">
					<td colspan="2" align="center"><input type="button"
						value="์ˆ˜์ •๋ฐ˜์˜ํ•˜๊ธฐ" onclick="fn_modify_article(frmArticle)" /> <input
						type="button" value="์ทจ์†Œ" onclick="backToList(frmArticle)" /></td>
				</tr>
				<tr id="tr_btn">
					<td colspan="2" align="center"><br> <input type="button"
						value="์ˆ˜์ •ํ•˜๊ธฐ" onclick="fn_enable()" /> <input
						type="button" value="์‚ญ์ œํ•˜๊ธฐ"
						onclick="fn_remove_article('${contextPath}/board/removeArticle', ${article.articleNo} })" />
						<input type="button" value="๋ฆฌ์ŠคํŠธ๋กœ ๋Œ์•„๊ฐ€๊ธฐ"
						onclick="backToList(frmArticle)" /></td>
				</tr>
			</tbody>
		</table>
	</form>
</body>
</html>

 

   โ””web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>BoardProject</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<servlet>
		<servlet-name>dispatcher</servlet-name>
		<servlet-class>
			org.springframework.web.servlet.DispatcherServlet
		</servlet-class>
		<init-param>
			<param-name>contextClass</param-name>
			<param-value>
				org.springframework.web.context.support.AnnotationConfigWebApplicationContext
			</param-value>
		</init-param>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>
				com.gyuone.config.MvcConfig
				com.gyuone.config.ControllerConfig
			</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>dispatcher</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

 

 

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.gyuone</groupId>
	<artifactId>BoardProject</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.1</version>
				<configuration>
					<release>11</release>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>3.2.3</version>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>4.0.1</version>
			<scope>provided</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>javax.servlet.jsp-api</artifactId>
			<version>2.3.3</version>
			<scope>provided</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>5.3.22</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>8.0.29</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.5.10</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>2.0.7</version>
		</dependency>

	</dependencies>

</project>

 

 

 

 

 


 

๋Œ“๊ธ€