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

[40์ผ์ฐจ] ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ(3) delete. update ์ถ”๊ฐ€ ๐ŸŒ€ ์ตœ์ข… ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ

by GWLEE 2022. 8. 17.

๋…นํ™”_2022_08_17_17_21_58_185.mp4
4.44MB

๐Ÿš™2022-08-17๐Ÿš™

 

 

 

https://github.com/GyuWonLee/FinalBoardProject

 

GitHub - GyuWonLee/FinalBoardProject

Contribute to GyuWonLee/FinalBoardProject development by creating an account on GitHub.

github.com

 

com.gyuone

โ”” 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.controller.RestSvcController;
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();
	}
	
	@Bean
	RestSvcController restSvcController() {
		return new RestSvcController();
	}
}

 

   โ””  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.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

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>();
	
	Logger logger = LoggerFactory.getLogger("com.gyuone.controller.BoardController");
	
	@RequestMapping({"/listArticles","/"}) // ๋ฐฐ์—ด๋กœ ๋•Œ๋ฆผ
	public String getArticleList(Model model) {
		logger.info("===============> getArticleList ๋ฉ”์„œ๋“œ ์ง„์ž…");
		articleList = boardService.listArticles();
		model.addAttribute("articleList", articleList);
		return "listArticles";
	}
	
	@RequestMapping("/mlist")
	@ResponseBody
	public List<ArticleVO> getArticleListForMobile() {
		articleList = boardService.listArticles();
		return articleList;
	}
	
	
	@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;
	}
	
	@RequestMapping(value="/editArticle", method=RequestMethod.POST)
	public String editArticle(@RequestParam(value="articleNo") String articleNo,
			@RequestParam(value="title") String title, @RequestParam(value="content") String content,
			RedirectAttributes redirect) {
		articleVo.setArticleNo(Integer.parseInt(articleNo));
		articleVo.setTitle(title);
		articleVo.setContents(content);
		articleVo.setWriteId("bit");
		boardService.editArticle(articleVo);
		
		redirect.addAttribute("articleno", articleNo);
		return "redirect:viewArticle";
	}
	
	@RequestMapping(value="/removeArticle", method=RequestMethod.POST)
	public String removeArticle(@RequestParam(value="articleNo") String articleNo) {
		boardService.removeArticle(Integer.parseInt(articleNo));
		return "redirect:listArticles";
	}
}

 

    โ”” RestSvcController.java

package com.gyuone.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping("/rest")
public class RestSvcController {
	@Autowired
	ArticleVO articleVo;
	@Autowired
	BoardService boardService;
	
	Logger logger = LoggerFactory.getLogger("com.gyuone.controller.RestSvcController");

	@RequestMapping("/hello")
	public String hello() {
		logger.info("====> hello() ์ง„์ž…");
		return "Hello REST!!!!";
	}
	
	@RequestMapping(value="/article/{num}", method=RequestMethod.GET)
	public ArticleVO getArticle(@PathVariable("num") int articleNo) { // num ๋ณ€์ˆ˜ 
		articleVo = boardService.viewArticle(articleNo); // articleVo ํ†ต์งธ๋กœ ๋„˜๊ฒจ๋ฒ„๋ฆผ
		return articleVo;
	}
	
}

 

โ”” 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;
	}
	
	public void editArticle(ArticleVO article) {
		boardDao.updateArticle(article);
	}
	
	public void removeArticle(int articleNo) {
		boardDao.deleteArticle(articleNo);
	}
	
}

 

 

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 type="articleVO" id="articleResult">
		<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}, WriteDate=default
			where ArticleNo=#{articleNo}
		]]>
	</update>
	<delete id="deleteArticle" parameterType="int">
		delete from noticeboard where ArticleNo=#{articleNo}
	</delete>
</mapper>

 

   โ””  logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<property name="LOG_PATH" value="E:/tmp/logs" />

	<appender name="STDOUT"
		class="ch.qos.logback.core.ConsoleAppender">
		<target>System.out</target>
		<encoder>
			<pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] [%-5level]
				%logger{35} - %msg%n</pattern>
		</encoder>
	</appender>
	<appender name="ROLLING"
		class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${LOG_PATH}/logback.log</file>
		<append>true</append>
		<encoder
			class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] [%-5level]
				%logger{35} - %msg%n</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>INFO</level>
		</filter>
		<rollingPolicy 
			class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<fileNamePattern>${LOG_PATH}/logback.%d{yyyy-MM-dd}.%i.log.zip
			</fileNamePattern>
			<maxFileSize>5MB</maxFileSize>
			<maxHistory>30</maxHistory>
		</rollingPolicy> <!-- ๋กค๋ง ์ •์ฑ… 30์ผ ๋ถ„๋Ÿ‰์˜ ๋กœ๊ทธ ํŒŒ์ผ์€ ์œ ์ง€๊ฐ€ ๋˜๊ณ  30์ผ ์ด์ „์˜ ๋กœ๊ทธ ํŒŒ์ผ์€ ์‚ญ์ œ-->
	</appender>


	<root level="info">
		<appender-ref ref="ROLLING" />
		<appender-ref ref="STDOUT" />
	</root>
</configuration>

 

   โ””  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>

 

 

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;
}

h1{
  position: relative;
  animation: mymove infinite;
  animation-duration: 3s;
  color: blue;
  animation-fill-mode: forwards;
}

@keyframes mymove {
  from {top: 0px;}
  to {top: 30px; 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: blue;">๊ธ€ ๋ชฉ๋ก</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>
				<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>
	<a class="cls1" href="${contextPath}/board/newArticle">
	<br><br>
		<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>
<style type="text/css">
#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';
}

.cls1 {
	text-decoration: none;
}

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

a:hover {
	color: #153acf;
}

button:hover{
	background-color: #c0d9fc;
}
</style>
<script type="text/javascript">
	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";
	}
	
	function fn_modify_article(frm) {
		frm.action = "${contextPath}/board/editArticle";
		frm.submit();
	}
	
	/* function fn_remove_article(frm) {
		frm.action = "${contextPath}/board/removeArticle";
		frm.submit();
	} */
	
	function fn_remove_article(url, articleNo) {
		let form = document.createElement("form");
		form.setAttribute("method", "POST");
		form.setAttribute("action", url);
		let articleNoInput = document.createElement("input");
		articleNoInput.setAttribute("type", "hidden");
		articleNoInput.setAttribute("name", "articleNo");
		articleNoInput.setAttribute("value", articleNo);
		
		form.appendChild(articleNoInput);
		document.body.appendChild(form);
		form.submit();
	}
		
</script>
</head>
<body>
<h1 style="text-align: center; color:#c0d9fc;">์ƒˆ ๊ธ€ ์“ฐ๊ธฐ</h1>
	<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 /> <input type="hidden"
						name="articleNo" value="${article.articleNo}" /></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">
						<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="fn_remove_article(frmArticle)" />  -->
						<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>
		<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>1.2.11</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
		<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>1.7.36</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.13.3</version>
		</dependency>
	</dependencies>

</project>

๋Œ“๊ธ€