ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•
BoardController.java

๊ฒŒ์‹œํŒ ํ™”๋ฉด ์š”์ฒญ GET์š”์ฒญ

package com.spring.myapp.board.controller;

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.servlet.mvc.support.RedirectAttributes;

import com.spring.myapp.board.model.BoardVO;
import com.spring.myapp.board.service.IBoardService;

//๊ฒŒ์‹œํŒ ์ž์› ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•ด ์ค„ ์ปจํŠธ๋กค๋Ÿฌ์ด๋‹ค. -> ๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด ๋นˆ๋“ฑ๋ก์„ ํ•ด์ฃผ์–ด์•ผํ•œ๋‹ค.
@Controller //์ปจํŠธ๋กค๋Ÿฌ ๋นˆ๋“ฑ๋กํ•ด์ฃผ๋Š” ์–ด๋…ธํ…Œ์ด์…˜
@RequestMapping("/board") //"/board"์š”์ฒญ์ด ๋“ค์–ด์˜ฌ ๋•Œ ๋‹ค ์—ฌ๊ธฐ์„œ ์ฒ˜๋ฆฌํ•˜๊ฒ ๋‹ค ํ•˜๋Š” ๊ณตํ†ต URL์ž‘์„ฑ!!
public class BoardController {
	
	//๋กœ๊ฑฐ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋กœ๊ฑฐ๊ฐ์ฒด ์„ ์–ธ
	private static final Logger logger = LoggerFactory.getLogger(BoardController.class);
	
	//์ปจํŠธ๋กค๋Ÿฌ์™€ ์„œ๋น„์Šค๊ฐ€ ์˜์กด๊ด€๊ณ„๊ฐ€ ์„ค์ •๋˜์–ด์žˆ์œผ๋‹ˆ ์˜์กด์„ฑ์ฃผ์ž…ํ•ด์ค€๋‹ค.
	@Autowired
	private IBoardService service;
	
	
	
	
	
///////////////////// ์—ด๋žŒ ์š”์ฒญ [GET] ////////////////////////
	//๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ํŽ˜์ด์ง€ ์—ด๋žŒ ์š”์ฒญ(๋ชจ๋“  ๊ฒŒ์‹œ๋ฌผ ์กฐํšŒ) ์ฒ˜๋ฆฌ ๋ฉ”์„œ๋“œ -> ์ด ๋ฉ”์„œ๋“œ์˜ ํŠธ๋ฆฌ๊ฑฐ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ ์ ์–ด์ค˜์•ผํ•œ๋‹ค.
	// '/list'๋ผ๋Š” ์š”์ฒญ์ด์˜ค๋ฉด ์ด ๋ฉ”์„œ๋“œ๊ฐ€ ์ž‘๋™, GET๋ฐฉ์‹๋งŒ ๋ฐ›๋„๋ก ๋ฉ”์„œ๋“œ์†์„ฑ๋„ ์ ์–ด์ค€๋‹ค.
	@RequestMapping(value="/list", method=RequestMethod.GET) 
	public String list (
			/* 
			 * ๊ฐ’์„ ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ๋ฒ• 
			 * 1. "HttpServletReqeust req" ์„ ์–ธ
			 * 2. "@RequestParam("aaa") String aaa, @RequestParam("bbb") String bbb" ์„ ์–ธ
			 * 3. ์ปค๋งจ๋“œ ๊ฐ์ฒด ์ด์šฉ : ๊ฐ€์ ธ์˜ฌ ์ปค๋งจ๋“œ ๊ฐ์ฒด "Box b" ์„ ์–ธ,
			 * 		Model model ์„ ์–ธ (๋ชจ๋ธ์€ ๋ฐ์ดํ„ฐ๋“ค์„ ๋‹ด์„ ์ˆ˜ ์žˆ๋Š” ๊ณต๊ฐ„์œผ๋กœ viewํ™”๋ฉด์— ๋ฟŒ๋ ค์ฃผ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค.)
			 * */
			Model model
			) throws Exception {
		
		logger.info("/board/list : GET ์š”์ฒญ ๋ฐœ์ƒ!");
		System.out.println("๊ฒŒ์‹œ๊ธ€ ํŽ˜์ด์ง€ ์—ด๋žŒ ์š”์ฒญ!");
		
		//1. HttpServletReqeust req ๋ฐฉ๋ฒ•
//		System.out.println("aaa : " + req.getParameter("aaa"));
//		System.out.println("bbb : " + req.getParameter("bbb"));
		
		//2. @RequestParam ๋ฐฉ๋ฒ•
//		System.out.println("aaa : " + aaa);
//		System.out.println("bbb : " + bbb);
		
		//3. ์ปค๋งจ๋“œ ๊ฐ์ฒด ๋ฐฉ๋ฒ•
//		System.out.println("aaa : " + b.getAaa());
//		System.out.println("bbb : " + b.getBbb());
		
		//๋ชจ๋ธ์— ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด๋Š” ๊ณผ์ • - view์—์„œ๋Š” ""์— ์ ์€ ์ด๋ฆ„์„ ELํƒœ๊ทธ๋ฅผ ์ด์šฉํ•ด ์‚ฌ์šฉํ•œ๋‹ค.
//		model.addAttribute("aaaa", b.getAaa());
//		model.addAttribute("bbbb", b.getBbb());
		
		
		//์ฝ˜์†”์ฐฝ์— ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ๋„์šฐ๊ธฐ
		List<BoardVO> articles = service.getAllArticles();
		System.out.println("=====================");
		for(BoardVO vo : articles)
			System.out.println(vo);
		System.out.println("=====================");
		
		//DB์—์„œ ๊ฐ€์ ธ์˜จ ๋ฐ์ดํ„ฐ๋ฅผ articles๋ผ๋Š” ์ด๋ฆ„์˜ ๋ชจ๋ธ์— ๋‹ด๋Š”๋‹ค.
		model.addAttribute("articles", service.getAllArticles());
		
		return "board/list";
	}
	
	//๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑํ™”๋ฉด ์—ด๋žŒ์š”์ฒญ
	@RequestMapping(value="/write", method=RequestMethod.GET)
	public String write() {
				
		logger.info("/board/write : GET ์š”์ฒญ ๋ฐœ์ƒ!");
		return "board/write";
	}
	
	//์ƒ์„ธ ํŽ˜์ด์ง€ ํ™”๋ฉด ์—ด๋žŒ ์š”์ฒญ
	@RequestMapping(value="/content", method=RequestMethod.GET)
	public String content(@RequestParam("boardNo") int boardNo, Model model) throws Exception {
		//๊ฒŒ์‹œ๋ฌผ์˜ ๋ฒˆํ˜ธ๋ฅผ requestparam์œผ๋กœ ๊ฐ€์ ธ์˜จ๋‹ค
		
		logger.info("/board/content : GET ์š”์ฒญ ๋ฐœ์ƒ!");
		
		//DB์—์„œ ์—ฐ๊ฒฐํ•ด ๊ฐ€์ ธ์˜จ ๊ฒŒ์‹œ๋ฌผ์„ article์ด๋ผ๋Š” ์ด๋ฆ„์˜ ๋ชจ๋ธ์— ๋‹ด๋Š”๋‹ค.
		model.addAttribute("article", service.getArticle(boardNo));
		
		return "board/content";
	}
	
	//๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ • ํ™”๋ฉด ์—ด๋žŒ ์š”์ฒญ
	@RequestMapping(value="/modify", method=RequestMethod.GET)
	public String modify(@RequestParam("boardNo") int boardNo, Model model) throws Exception {
		
		
		logger.info("/board/modify : GET ์š”์ฒญ ๋ฐœ์ƒ!");
		
		//requestParam์œผ๋กœ ๊ธ€๋ฒˆํ˜ธ๋ฅผ ๊ฐ€์ ธ์˜จ๋’ค ๊ธ€๋ฒˆํ˜ธ๋กœ ๊ฒŒ์‹œ๊ธ€ ์ „์ฒด๋ฅผ ์กฐํšŒํ•˜๊ณ  article์ด๋ฆ„์˜ ๋ชจ๋ธ์— ๋‹ด๋Š”๋‹ค.
		model.addAttribute("article", service.getArticle(boardNo));
		
		return "board/modify";
	}

 

๊ฒŒ์‹œํŒ ๊ธฐ๋Šฅ ์š”์ฒญ POST์š”์ฒญ

/////////////////// ๊ฒŒ์‹œํŒ ๊ธฐ๋Šฅ ์š”์ฒญ [POST] ///////////////////////
	//๊ฒŒ์‹œ๋ฌผ ๋“ฑ๋ก ๊ธฐ๋Šฅ ๋ฉ”์„œ๋“œ ์š”์ฒญ (๊ฐ™์€ ์ด๋ฆ„์œผ๋กœ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์ˆ˜์žˆ๋‹ค. ์˜ค๋ฒ„๋กœ๋”ฉ)
	@RequestMapping(value="/write", method=RequestMethod.POST)
	public String write(BoardVO article, RedirectAttributes redirectAttr) throws Exception {
		
		logger.info("/board/write : POST ์š”์ฒญ !");
		logger.info("๊ฐ€์ ธ์˜จ ๊ฒŒ์‹œ๊ธ€ ํ™•์ธ : " + article.toString());
		
		service.insert(article); //๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก ์š”์ฒญ
		
		
		//๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก์„ ํ•˜๊ณ  alert์œผ๋กœ ์ž˜ํ–ˆ๋‹ค~ ๋ผ๊ณ  ์•Œ๋ ค์ฃผ๊ธฐ ์œ„ํ•ด ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ๋ฅผ ํ•  ๋•Œ ์ž„์‹œ ๋ฐ์ดํ„ฐ(๊ทธ ์ˆœ๊ฐ„๋งŒ)๋ฅผ ์˜๋Š” ๋ฐฉ๋ฒ•
		redirectAttr.addFlashAttribute("message", "regSuccess");
		//list.jsp ์—์„œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ์‚ฌ์šฉ
		
		
		/*
		 * ๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก์ด ๋๋‚˜๋ฉด ๋‹ค์‹œ ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก์ด ๋‚˜์™€์•ผํ•œ๋‹ค. ์ด๋•Œ ๊ทธ๋ƒฅ jspํŒŒ์ผ์„ ๋ถˆ๋Ÿฌ์˜ค๋ฉด ์•ˆ๋˜๊ณ  
		 * ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก์€ ํ•ญ์ƒ DB๋ฅผ ๊ฑฐ์ณ์„œ ๋ชฉ๋ก์„ ์ƒˆ๋กœ ๊ฐ€์ ธ์™€์•ผํ•œ๋‹ค. -> ๋‹ค์‹œ ํ•œ ๋ฒˆ ๋ชฉ๋ก ์žฌ์š”์ฒญ์„ ํ•ด์•ผํ•จ 
		 * ์žฌ์š”์ฒญ์ด ์žˆ์„ ๋•Œ๋Š” redirect:/
		 */
		return "redirect:/board/list";
	}
		
	
	//๊ฒŒ์‹œ๋ฌผ ์ˆ˜์ • ๊ธฐ๋Šฅ ๋ฉ”์„œ๋“œ ์š”์ฒญ
	@RequestMapping(value="/modify", method=RequestMethod.POST)
	public String modify(BoardVO article, RedirectAttributes redirectAttr) throws Exception {
		
		logger.info("/board/modify : POST ์š”์ฒญ !");
		service.update(article); //๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ • ์š”์ฒญ
		
		redirectAttr.addFlashAttribute("message", "modSuccess"); //์ˆ˜์ • ์„ฑ๊ณต ์‹œ ์ž„์‹œ๋ฐ์ดํ„ฐ
		
		return "redirect:/board/content?boardNo="+article.getBoardNo();
	}
	
	
	//๊ฒŒ์‹œ๋ฌผ ์‚ญ์ œ ๊ธฐ๋Šฅ ๋ฉ”์„œ๋“œ ์š”์ฒญ
	@RequestMapping(value="/delete", method=RequestMethod.POST)
	public String delete(@RequestParam("boardNo") int boardNo, RedirectAttributes redirectAttr) throws Exception {
		
		logger.info("/board/delete : POST ์š”์ฒญ !");
		service.delete(boardNo);
		
		redirectAttr.addFlashAttribute("message", "delSuccess"); //์‚ญ์ œ ์„ฑ๊ณต ์‹œ ์ž„์‹œ ๋ฐ์ดํ„ฐ
		
		
		return "redirect:/board/list";
	}

 

 

 

 

 

viewํ™”๋ฉด - 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>
<html>
<jsp:include page="../include/static-head.jsp"/>
<body>
		

	<div class="container-fluid">
		<jsp:include page="../include/menu-bar.jsp"/>
	
		<div class="container" style="margin-top: 70px;">
			<div class="wrap_title">
				<h2>๊ฒŒ์‹œํŒ<small>๋ชฉ๋กํŽ˜์ด์ง€</small></h2>
				<%-- ๊ฒŒ์‹œ๋ฌผ ๋ณด์ด๋Š” ๊ฐœ์ˆ˜ ๋ฐ”๊พธ๊ธฐ --%>
				<span id="count-per-page" style="float: right;">
					<i class="fa fa-list">๋ชฉ๋ก๋ณด๊ธฐ</i>
					<input class="btn" type="button" value="10">
					<input class="btn" type="button" value="20">
					<input class="btn" type="button" value="30">			
				</span>
			</div>
			
			<%-- ๊ฒŒ์‹œ๋ฌผ ์‹œ์ž‘ ๋ถ€๋ถ„ --%>
			<div class="list_content">
				<table class="table table-hover">
			      <thead>
			        <tr>
			          <th width="10%">๋ฒˆ ํ˜ธ </th>
			          <th width="50%">์ œ ๋ชฉ</th>
			          <th width="30%">๊ธ€์“ด์ด</th>
			          <th width="10%">์กฐํšŒ</th>
			        </tr>
			      </thead>
			      
			      <%-- ๊ฒŒ์‹œ๋ฌผ์ด ๋“ค์–ด๊ฐˆ ๊ณต๊ฐ„:์ปจํŠธ๋กค๋Ÿฌ์—์„œ articles๋ผ๋Š” ์ด๋ฆ„์˜ ๋ชจ๋ธ์— ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด์•˜๊ธฐ ๋•Œ๋ฌธ์— elํƒœ๊ทธ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. --%>
			      <c:if test="${articles.size() <=0 }">
			      	<!-- ๋ชจ๋ธ์— ๋‹ด์€ articles ํฌ๊ธฐ๊ฐ€ 0๋ณด๋‹ค ์ž‘์œผ๋ฉด ๋‚˜ํƒ€๋‚˜๋Š” ๊ณณ -->
			      	<td colspan="4" align="center"><strong>๋“ฑ๋ก๋œ ๊ฒŒ์‹œ๋ฌผ์ด ์—†์Šต๋‹ˆ๋‹ค !</strong></td>
			      </c:if>
			      <c:if test="${articles.size() > 0 }">
			      	<!-- ๊ฒŒ์‹œ๋ฌผ ์ˆ˜๊ฐ€ ์กด์žฌํ•  ๋•Œ ๋ณด์—ฌ์ง€๋Š” ๊ณณ -->
			      	<!-- articles(listํƒ€์ž…)๋ฅผ ๊บผ๋‚ด์„œ article(BoardVOํƒ€์ž…)์— ํ•˜๋‚˜์”ฉ ๋‹ด๋Š”๋‹ค. -->
			      	<c:forEach var="article" items="${articles }">
			      		<tr>
			      			<td>${article.boardNo }</td>
			      			<!-- ๊ธ€๋ฒˆํ˜ธ๋กœ ๊ฒŒ์‹œ๊ธ€์„ ์กฐํšŒํ•ด์•ผํ•˜๋‹ˆ๊นŒ ๊ธ€๋ฒˆํ˜ธ๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋‹ฌ์•„์ค€๋‹ค. -->
							<td><a href="<c:url value='/board/content?boardNo=${article.boardNo }' />"> ${article.title }</a></td>
							<td>${article.writer }</td>
							<td>${article.viewCnt }</td>
			      		</tr>
			      	</c:forEach>
			      </c:if>
			      
			    </table>
			</div>
			<div class="list_paging">
				
			</div>
			<button type="button" class="btn btn-success btn-flat" id="writeBtn">
			    <i class="fa fa-pencil"></i> ๊ธ€์“ฐ๊ธฐ
			</button>
		</div>
		<jsp:include page="../include/footer.jsp"/>
	</div>
	
	
	<script type="text/javascript">
		const result = "${message}"; //์ƒ์ˆ˜์ฒ˜๋ฆฌ
		if(result === "regSuccess") {//๋™๋“ฑ๋น„๊ต ===์‚ฌ์šฉ
			alert("๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
		} else if (result === "delSuccess") {
			alert("๊ฒŒ์‹œ๊ธ€ ์‚ญ์ œ๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
		}
		
		$(document).ready(function() {
			
			//๊ธ€์“ฐ๊ธฐ ๋ฒ„ํŠผ ํด๋ฆญ ์ด๋ฒคํŠธ
			$("#writeBtn").on("click", function(){
				self.location = "/mvc/board/write";
			});
		
		});
		
		
	</script>
	
	
</body>
</html>
 

 

 

 

 

viewํ™”๋ฉด - 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>
<html>
<jsp:include page="../include/static-head.jsp"/>
<body>
	<div class="container-fluid">
		<jsp:include page="../include/menu-bar.jsp"/>
			<div class="container" style="margin-top: 70px;">
				<div class="wrap_title">
					<h2>๊ฒŒ์‹œํŒ<small>์ž‘์„ฑํŽ˜์ด์ง€</small></h2>
				</div>
				<form id="writeForm" method="post" action="<c:url value='/board/write' />">
					<div class="content_title form-group">
						<label for="title">๊ธ€์ œ๋ชฉ</label>
						<input class="form-control" id="title" name="title" placeholder="์ œ๋ชฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”" value="">
					</div>
					<div class="content_content form-group">
						<label for="content">๋‚ด์šฉ</label>
							<textarea class="form-control" id="content" name="content" rows="10" placeholder="๋‚ด์šฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”" style="resize: none;">๊ธ€๋‚ด์šฉ</textarea>
					</div>
					<div class="form-group">
						<label for="writer">์ž‘์„ฑ์ž</label>
						<input class="form-control" id="writer" name="writer" value="์ž‘์„ฑ์ž๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.">
					</div>
					<div class="list_paging">
						
					</div>
					<button type="button" class="btn btn-primary"><i class="fa fa-list"></i> ๋ชฉ๋ก</button>
				    <button type="reset" class="btn btn-warning"><i class="fa fa-reply"></i> ์ดˆ๊ธฐํ™”</button>
				    <button type="submit" class="btn btn-success"><i class="fa fa-save"></i> ์ž…๋ ฅ</button>
			    </form>
			</div>
		<jsp:include page="../include/footer.jsp"/>
	</div>
</body>
</html>

 

 

 

 

viewํ™”๋ฉด - content.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>
<html>
<jsp:include page="../include/static-head.jsp"/>
<body>
	<div class="container-fluid">
		<jsp:include page="../include/menu-bar.jsp"/>
		<div class="container" style="margin-top: 70px;">
			<div class="wrap_title">
				<h2>๊ฒŒ์‹œํŒ<small>์ƒ์„ธํŽ˜์ด์ง€</small></h2>
			</div>
			<div class="content_title">
				<strong>${article.title }</strong>
				<span>
					<!-- fmt๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ : ๋‚ ์งœ ํ˜•์‹ ์ œ๊ณต - ์œ„์ชฝ์— ํƒœ๊ทธ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ ์–ธํ•ด์•ผํ•œ๋‹ค. -->
					<fmt:formatDate pattern="yyyy-MM-dd a HH:mm" value="${article.regDate }"/>
				</span>
			</div>
			<div class="content_content" style="height: 350px;">
				${article.content }
			</div>
			<div>
				<span class="username">${article.writer }</span>
			</div>
			
			
			<form role="form" method="post">
				<input type="hidden" name="boardNo" value="${article.boardNo }">
			</form>
			
			<button class="btn btn-primary listBtn">
				<i class="fa fa-list"></i> ๋ชฉ๋ก
			</button>
			<button class="btn btn-warning modBtn">
				<i class="fa fa-edit"></i> ์ˆ˜์ •
			</button>
			<button class="btn btn-danger delBtn">
				<i class="fa fa-trash"></i> ์‚ญ์ œ
			</button>

		</div>
		<jsp:include page="../include/footer.jsp"/>
	</div>

<script type="text/javascript">
	$(document).ready(function () {
		
		const formObj = $("form[role='form']");
		
		$(".listBtn").on("click", function() {
			formObj.attr("method", "get");
			formObj.attr("action", "list");
			formObj.submit();
		});
		
		$(".modBtn").on("click", function() {
			formObj.attr("method", "get");
			formObj.attr("action", "modify");
			formObj.submit();
		});
		
		$(".delBtn").on("click", function() {
			formObj.attr("method", "post");
			formObj.attr("action", "delete");
			formObj.submit(); 
		});
	});

</script>


<script type="text/javascript">
	const result = "${message}"; //์ƒ์ˆ˜์ฒ˜๋ฆฌ
	if(result === "modSuccess") {//๋™๋“ฑ๋น„๊ต ===์‚ฌ์šฉ
		
		alert("๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ •์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
	}
</script>




</body>
</html>

 

 

 

 

viewํ™”๋ฉด - modify.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>
<jsp:include page="../include/static-head.jsp"/>
<body>
	<div class="container-fluid">
		<jsp:include page="../include/menu-bar.jsp"/>
		<div class="container" style="margin-top: 70px;">
			<div class="wrap_title">
				<h2>๊ฒŒ์‹œํŒ<small>์ˆ˜์ •ํŽ˜์ด์ง€</small></h2>
			</div>
			<form role="form" id="modifyForm" method="post" action="<c:url value='/board/modify'/>">
				<input type="hidden" id="boardNo" name="boardNo" value="${article.boardNo }">
				
				<div class="content_title form-group">
					<label for="title">๊ธ€์ œ๋ชฉ</label>
					<input class="form-control" id="title" name="title" placeholder="์ œ๋ชฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”" value="${article.title}">
				</div>
				<div class="content_content form-group">
					<label for="content">๋‚ด์šฉ</label>
						<textarea class="form-control" id="content" name="content" rows="10" placeholder="๋‚ด์šฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”" style="resize: none;">${article.content }</textarea>
				</div>
				<div class="form-group">
					<label for="writer">์ž‘์„ฑ์ž</label>
					<input class="form-control" id="writer" name="writer" value="${article.writer}" readonly>
				</div>
				<div class="list_paging">
					
				</div>
				<button type="button" class="btn btn-primary listBtn"><i class="fa fa-list"></i> ๋ชฉ๋ก</button>
			    <button type="button" class="btn btn-warning cancelBtn"><i class="fa fa-trash"></i> ์ทจ์†Œ</button>
			    <button type="submit" class="btn btn-success modBtn"><i class="fa fa-save"></i> ์ˆ˜์ • ์ €์žฅ</button>
			</form>
		</div>
		<jsp:include page="../include/footer.jsp"/>
	</div>

<script>
    $(document).ready(function () {

        const formObj = $("form[role='form']");        

        $(".modBtn").on("click", function () {
            formObj.submit();
        });

        $(".cancelBtn").on("click", function () {
            history.back();
        });

        $(".listBtn").on("click", function () {
            self.location = "list";
        });

    });
</script>


</body>
</html>
๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€