위로
아래
전체 파일 구조
Controller 전체 코드
더보기
package com.ecom4.hi.board.control;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 com.ecom4.hi.HomeController;
import com.ecom4.hi.board.model.BoardDTO;
import com.ecom4.hi.board.model.PageDTO;
import com.ecom4.hi.board.model.RowInterPage;
import com.ecom4.hi.board.service.BoardService;
@Controller
public class BoardController {
private static final Logger logger = LoggerFactory.getLogger(BoardController.class);
//JavaBoard에서 작업했던 Action 역할을 하는 객체 - 비즈니스 로직 BIZ를 갖고 있다
@Autowired
private BoardService boardService;
@RequestMapping(value = "/list")
public String getArticles(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto){
logger.info("리스트 컨트롤러에 들어왔다");
Map<String, Object> resultSet = boardService.getArticles(dto, pdto);
//List<BoardDTO> articles = boardService.getArticles(dto);
model.addAttribute("articles",resultSet.get("articles"));
model.addAttribute("totalCnt",resultSet.get("totalCnt"));
model.addAttribute("pdto",resultSet.get("pdto"));
model.addAttribute("pBlock",RowInterPage.PAGE_OF_BLOCK);
return "board/BoardList";
}
@RequestMapping(value = "/writeForm")
public String writeForm(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto) {
logger.info("글쓰기 컨트롤러에 들어왔다");
logger.info("dto==>"+dto.getBno()+"::"+pdto.getCurPage());
model.addAttribute("article", dto);
model.addAttribute("pdto", pdto);
return "board/BoardWriteForm";
}
@RequestMapping(value = "/writeAction")
public String writeAction(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto) {
dto.setIp(request.getRemoteAddr());
boardService.writeArticle(dto);
model.addAttribute("pdto",pdto);
return "redirect:list?curPage="+pdto.getCurPage();
}
@RequestMapping(value = "/content")
public String getArticle(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto) {
logger.info("글보기에 들어왔다");
BoardDTO article = boardService.getArticle(dto);
model.addAttribute("article", article);
model.addAttribute("pdto", pdto);
return "board/BoardContent";
}
@RequestMapping(value = "/update")
public String updateArticle(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto) {
model.addAttribute("article", dto);
model.addAttribute("pdto", pdto);
return "board/BoardUpdate";
}
@RequestMapping(value = "/updateAction")
public String updateAction(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto) {
dto.setIp(request.getRemoteAddr());
int r = boardService.updateArticle(dto);
String msg ="";
if(r==0) {
msg = "수정 실패";
} else if(r==1) {
msg = "수정 성공";
}
model.addAttribute("article", dto);
model.addAttribute("pdto", pdto);
model.addAttribute("msg",msg);
model.addAttribute("page","list?curPage"+pdto.getCurPage());
return "board/MsgPage";
}
@RequestMapping(value = "/delete")
public String deleteArticle(HttpServletRequest request, HttpServletResponse response,
BoardDTO dto, Model model, PageDTO pdto) {
int r = boardService.deleteArticle(dto);
String msg = "";
if(r==0) {
msg = "삭제 실패";
} else if(r==1) {
msg = "삭제 성공";
}
model.addAttribute("pdto",pdto);
model.addAttribute("msg", msg);
model.addAttribute("page","list?curPage="+pdto.getCurPage());
return "board/MsgPage";
}
}
Service 전체 코드
BoardService 인터페이스
더보기
package com.ecom4.hi.board.service;
import java.util.List;
import java.util.Map;
import com.ecom4.hi.board.model.BoardDTO;
import com.ecom4.hi.board.model.PageDTO;
public interface BoardService {
Map<String, Object> getArticles(BoardDTO dto, PageDTO pdto);
void writeArticle(BoardDTO dto);
BoardDTO getArticle(BoardDTO dto);
int updateArticle(BoardDTO dto);
int deleteArticle(BoardDTO dto);
}
BoardServiceImpl 구현 클래스
더보기
package com.ecom4.hi.board.service;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ecom4.hi.board.dao.BoardDAO;
import com.ecom4.hi.board.model.BoardDTO;
import com.ecom4.hi.board.model.PageDTO;
import com.ecom4.hi.board.model.RowInterPage;
@Service(value = "boardService")
public class BoardServiceImpl implements BoardService {
// DAO DI(Dependency Injection)
@Autowired
private BoardDAO boardDao;
@Override
public Map<String, Object> getArticles(BoardDTO dto, PageDTO pdto) {
Map<String, Object> resultSet = new HashMap<String, Object>();
if(pdto.getCurBlock()<0) pdto.setCurBlock(1);
if(pdto.getCurPage()<0) pdto.setCurPage(1);
int totalCnt = boardDao.getTotalCnt();
resultSet.put("totalCnt",totalCnt);
//현재 페이지 계산
int start = (pdto.getCurPage()-1)*RowInterPage.ROW_OF_PAGE + 1;
int end = (pdto.getCurPage()*RowInterPage.ROW_OF_PAGE)>totalCnt?
totalCnt:pdto.getCurPage()*RowInterPage.ROW_OF_PAGE;
dto.setStart(start);
dto.setEnd(end);
int pgCnt = (totalCnt%RowInterPage.ROW_OF_PAGE==0)?
totalCnt/RowInterPage.ROW_OF_PAGE : totalCnt/RowInterPage.ROW_OF_PAGE+1;
//페이지 블럭
int pgBlock = (pgCnt%RowInterPage.PAGE_OF_BLOCK==0)?
pgCnt/RowInterPage.PAGE_OF_BLOCK : pgCnt/RowInterPage.PAGE_OF_BLOCK+1;
int startPg = (pdto.getCurBlock()-1)*RowInterPage.PAGE_OF_BLOCK+1;
int endPg = (pdto.getCurBlock()*RowInterPage.PAGE_OF_BLOCK > pgCnt)?
pgCnt : pdto.getCurBlock()*RowInterPage.PAGE_OF_BLOCK;
pdto.setPgCnt(pgCnt);
pdto.setPgBlock(pgBlock);
pdto.setStartPg(startPg);
pdto.setEndPg(endPg);
resultSet.put("pdto",pdto);
resultSet.put("articles", boardDao.getArticles(dto));
return resultSet;
}
@Override
public void writeArticle(BoardDTO dto){
boardDao.writeAction(dto);
}
@Transactional // 둘 중에 하나만 되지 않고, 둘 다 되거나 둘 다 안 되게 할 때 쓰는 것
@Override
public BoardDTO getArticle(BoardDTO dto) {
//update - readcount
boardDao.updateReadCnt(dto);
//getArticle
BoardDTO article = boardDao.getArticle(dto);
return article;
}
@Override
public int updateArticle(BoardDTO dto) {
return boardDao.updateArticle(dto);
}
@Override
public int deleteArticle(BoardDTO dto) {
return boardDao.deleteArticle(dto);
}
}
Model 전체 코드
BoardDTO
더보기
package com.ecom4.hi.board.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class BoardDTO {
private int start;
private int end;
private int rn;
private int bno;
private int nbno;
private int bref;
private int bstep;
private int blevel;
private int readcount;
private String subject;
private String content;
private String writer;
private String regdate;
private String ip;
private String passwd;
}
PageDTO
더보기
package com.ecom4.hi.board.model;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class PageDTO {
private int pgCnt;
private int pgBlock;
private int curPage = 1;
private int curBlock = 1;
private int startPg = 1;
private int endPg = 1;
}
RowInterPage
더보기
package com.ecom4.hi.board.model;
public interface RowInterPage {
public static final int ROW_OF_PAGE = 6;
public static final int PAGE_OF_BLOCK = 3;
}
BoardDAO
더보기
package com.ecom4.hi.board.dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ecom4.hi.board.model.BoardDTO;
@Repository(value = "boardDao")
public class BoardDAO {
// 자원을 DI (의존성 주입)
@Autowired
private SqlSession sqlSession;
private String namespace = "board.BoardDAO.";
public List<BoardDTO> getArticles(BoardDTO dto) {
return sqlSession.selectList(namespace + "getArticles",dto);
}
public int getTotalCnt() {
return sqlSession.selectOne(namespace + "getTotalCnt");
}
public void writeAction(BoardDTO dto) {
sqlSession.insert(namespace + "writeAction", dto);
}
public void updateReadCnt(BoardDTO dto) {
sqlSession.update(namespace + "updateReadCnt", dto);
}
public BoardDTO getArticle(BoardDTO dto) {
return sqlSession.selectOne(namespace + "getArticle", dto);
}
public int updateArticle(BoardDTO dto) {
return sqlSession.update(namespace + "updateArticle",dto);
}
public int deleteArticle(BoardDTO dto) {
return sqlSession.delete(namespace + "deleteArticle",dto);
}
}
BoardSpMapper.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 = "board.BoardDAO">
<select id="getArticles" resultType="bvo">
SELECT *
FROM(SELECT ROWNUM AS rn, A.*
FROM(SELECT bno, bref, bstep, blevel, readcount,
subject, content, writer, regdate, ip, passwd
FROM board
ORDER BY bref DESC, bno, bstep) A)
WHERE rn BETWEEN #{start} AND #{end}
</select>
<select id="getTotalCnt" resultType="int">
SELECT COUNT(bno) FROM BOARD
</select>
<insert id="writeAction" parameterType="bvo">
<selectKey keyProperty="nbno" resultType="int" order="BEFORE">
SELECT NVL(MAX(bno),0)+1 AS nbno FROM board
</selectKey>
INSERT INTO board
(bno, bref, bstep, blevel, readcount,
subject, content, writer, regdate, ip, passwd)
VALUES (
#{nbno},
<choose>
<when test="bno>0">
#{bno},
#{bstep}+1,
#{blevel}+1,
</when>
<when test="bno==0 and bref==0">
#{nbno},
0,
0,
</when>
</choose>
#{readcount}, #{subject}, #{content}, #{writer}, SYSDATE, #{ip}, #{passwd}
)
</insert>
<update id="updateReadCnt" parameterType="bvo">
UPDATE board SET readcount = readcount+1
WHERE bno = #{bno}
</update>
<select id="getArticle" resultType="bvo" parameterType="bvo">
SELECT bno, bref, bstep, blevel, readcount,
subject, content, writer, regdate, ip, passwd
FROM board
WHERE bno = #{bno}
</select>
<update id="updateArticle" parameterType="bvo">
UPDATE board
SET
subject = #{subject},
writer = #{writer},
content = #{content},
regdate = SYSDATE,
ip = #{ip},
passwd = #{passwd}
WHERE bno = #{bno}
</update>
<delete id="deleteArticle">
DELETE FROM board
WHERE bno = #{bno}
</delete>
</mapper>
View 전체 코드
BoardWriteForm.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="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>글쓰기 폼</title>
<link rel="stylesheet" href="css/form.css" type="text/css">
<script src="jquery/jquery-3.7.0.min.js"></script>
<script src="js/form.js"></script>
</head>
<body>
<form name="form1" action="writeAction" method="post">
<table>
<tr><td colspan="2"><h3>게시글 쓰기</h3></td></tr>
<tr>
<th>제목</th>
<td>
<c:choose>
<c:when test = "${article.bno > 0}">
<input type="text" name="subject" title="제목" value="[답글] ">
</c:when>
<c:when test = "${article.bno == 0}">
<input type="text" name="subject" title="제목" value="">
</c:when>
</c:choose>
</td>
</tr>
<tr>
<th>작성자</th>
<td><input type="text" name="writer" class="chk" title="작성자"></td>
</tr>
<tr>
<th>글 내용</th>
<td><textarea name="content" class="chk" title="글내용"></textarea></td>
</tr>
<tr>
<th>비밀번호</th>
<td><input type="password" name="passwd" class="chk" title="비밀번호"></td>
</tr>
<tr>
<td colspan="2">
<input class="btn" type="button" value="글 저장" id="submit11">
<input class="btn" type="button" value="글 목록" onclick="location.href='list?curPage=${pdto.curPage}'">
</td>
</tr>
</table>
<input type="hidden" name="curPage" value="${pdto.curPage}">
<input type="hidden" name="bno" value="${article.bno}">
<input type="hidden" name="bref" value="${article.bref}">
<input type="hidden" name="bstep" value="${article.bstep}">
<input type="hidden" name="blevel" value="${article.blevel}">
</form>
</body>
</html>
BoardList.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="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>게시글 목록</title>
<link rel="stylesheet" href="css/list.css" type="text/css">
<script src="jquery/jquery-3.7.0.min.js"></script>
<script src="js/list.js"></script>
</head>
<body>
<div class="btn">
<a href="writeForm?curPage=${pdto.curPage}">글쓰기</a>
</div>
<table>
<thead>
<tr><th colspan="6">게시글 목록 (전체 게시글 수 : ${totalCnt})</th></tr>
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>최종수정일</th>
<th>조회수</th>
<th>아이피</th>
</tr>
</thead>
<tbody>
<c:choose>
<c:when test = "${fn:length(articles)==0}">
<tr>
<td colspan="6">게시글이 없습니다.</td>
</tr>
</c:when>
<c:when test = "${fn:length(articles)>0}">
<c:forEach var = "article" items = "${articles}" varStatus="i">
<tr>
<td class="col1">${article.rn}</td>
<td class="col2">
<c:choose>
<c:when test="${article.blevel==0}">
<img src="images/level.gif" width="5px;">
</c:when>
<c:when test="${article.blevel>0 }">
<img src="images/level.gif" width="${article.blevel*10}px;" style="height:15px;">
<img src="images/re.gif">
</c:when>
</c:choose>
<a class="content">
${article.subject}
<input type = "hidden" name="no" value="${article.bno}">
</a>
</td>
<td class="col3">${article.writer}</td>
<td class="col4">${article.regdate}</td>
<td class="col5">
${article.readcount}
<c:if test="${article.readcount>10}">
<img src="images/hot.gif" style="width:30px; height:15px;">
</c:if>
</td>
<td class="col6">${article.ip}</td>
</tr>
</c:forEach>
</c:when>
</c:choose>
</tbody>
<tfoot>
<tr>
<td colspan="6" style="text-align:center;">
<c:if test = "${pdto.startPg > pBlock}">
<a href="list?curPage=${pdto.startPg-1}&curBlock=${pdto.curBlock-1}">[이전]</a>
</c:if>
<c:forEach begin="${pdto.startPg}" end="${pdto.endPg}" var="p" step="1">
<c:choose>
<c:when test="${p==pdto.curPage}">
<a href="list?curPage=${p}&curBlock=${pdto.curBlock}"><span style="font-weight:bold;"><c:out value="${p}"/></span></a>
</c:when>
<c:when test="${p!=pdto.curPage}">
<a href="list?curPage=${p}&curBlock=${pdto.curBlock}"><span><c:out value="${p}"/></span></a>
</c:when>
</c:choose>
</c:forEach>
<c:if test = "${pdto.endPg<pdto.pgCnt}">
<a href="list?curPage=${pdto.startPg+pBlock}&curBlock=${pdto.curBlock+1}">[다음]</a>
</c:if>
</td>
</tr>
</tfoot>
</table>
<form action="" method="post" name="content">
<input type="hidden" name="bno" value="${article.bno}">
<input type="hidden" name="curPage" value="${pdto.curPage}">
<input type="hidden" name="curBlock" value="${pdto.curPage}">
</form>
</body>
</html>
BoardContent.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="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>글내용</title>
<link rel="stylesheet" href="css/form.css" type="text/css">
<script src="jquery/jquery-3.7.0.min.js"></script>
<script src="js/content.js"></script>
</head>
<body>
<form name="form1" action="" method="post">
<table>
<tr><td colspan="2"><h3>글 내용</h3></td></tr>
<tr>
<th>제목</th>
<td><input type="text" name="subject" title="제목" value="${article.subject}" readonly="readonly"></td>
</tr>
<tr>
<th>작성자</th>
<td><input type="text" name="writer" title="작성자" value="${article.writer}" readonly="readonly"></td>
</tr>
<tr>
<th>IP</th>
<td><input type="text" name="ip" title="IP" value="${article.ip}" disabled="disabled"></td>
</tr>
<tr>
<th>작성일자</th>
<td><input type="text" name="regdate" title="작성일자" value="${article.regdate}" disabled="disabled"></td>
</tr>
<tr>
<th>글 내용</th>
<td><textarea name="content" title="글내용" readonly="readonly">${article.content}</textarea></td>
</tr>
<tr>
<th>비밀번호</th>
<td><input type="password" name="passwd" title="비밀번호" readonly="readonly" value="${article.passwd}"></td>
</tr>
<tr>
<td colspan="2">
<input class="btn" type="button" value="글 수정" id="update">
<input class="btn" type="button" value="글 삭제" id="delete">
<input class="btn" type="button" value="답글" id="reply">
<input class="btn" type="button" value="글 목록" onclick="location.href='list?curPage=${pdto.curPage}'">
</td>
</tr>
</table>
<input type="hidden" name="bno" value="${article.bno}">
<input type="hidden" name="bref" value="${article.bref}">
<input type="hidden" name="bstep" value="${article.bstep}">
<input type="hidden" name="blevel" value="${article.blevel}">
<input type="hidden" name="curPage" value="${pdto.curPage}">
</form>
</body>
</html>
BoardUpdate.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="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>글쓰기 폼</title>
<link rel="stylesheet" href="css/form.css" type="text/css">
<script src="jquery/jquery-3.7.0.min.js"></script>
<script src="js/form.js"></script>
</head>
<body>
<form name="form1" action="updateAction" method="post">
<table>
<tr><td colspan="2"><h3>게시글 수정</h3></td></tr>
<tr>
<th>제목</th>
<td><input type="text" name="subject" title="제목" class="chk" value="${article.subject}"></td>
</tr>
<tr>
<th>작성자</th>
<td><input type="text" name="writer" class="chk" title="작성자" value="${article.writer}"></td>
</tr>
<tr>
<th>글 내용</th>
<td><textarea name="content" class="chk" title="글내용">${article.content}</textarea></td>
</tr>
<tr>
<th>비밀번호</th>
<td><input type="password" name="passwd" class="chk" title="비밀번호" value="${article.passwd}"></td>
</tr>
<tr>
<td colspan="2">
<input class="btn" type="button" value="글 수정" id="submit11">
<input class="btn" type="reset" value="초기화">
<input class="btn" type="button" value="글 목록" onclick="location.href='list.do'">
</td>
</tr>
</table>
<input type="hidden" name="bno" value="${article.bno}">
<input type="hidden" name="bref" value="${article.bref}">
<input type="hidden" name="bstep" value="${article.bstep}">
<input type="hidden" name="blevel" value="${article.blevel}">
<input type="hidden" name="curPage" value="${pdto.curPage}">
</form>
</body>
</html>
MsgPage.jsp
더보기
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<script src = "jquery/jquery-3.7.0.min.js"></script>
<script>
$().ready(function(){
let msg = "${msg}";
alert(msg);
$(location).attr("href","${page}");
})
</script>
form.css
더보기
@charset "UTF-8";
* {margin:0; padding:0;}
table {
width:70%;
margin: 0 auto;
border:1px solid black;
background-color: #f6f6ee;
padding:10px;
border-radius:25px;
}
table th {
border : 1px solid balck;
}
table tr {text-align:center;}
table th {
text-align:center;
background-color : #ffffff;
border-radius:10px;
}
input {width:90%; heigh:30px; padding:3px;}
textarea {
width:90%; height:300px; padding:3px;
resize: none;
}
.btn {width:100px; margin-top:5px; margin-bottom:10px;}
h3 {margin:5px 5px 10px 5px;}
list.css
더보기
@charset "UTF-8";
*{margin:0; padding: 0;}
table {border:1px solid black; border-collapse: collapse; width:90%; margin:0 auto;}
th, td {border:1px solid black; border-collapse: collapse; padding:10px; margin:5px;}
th {background-color: #cfcfff;}
td {background-color: #ffffff; font-weight: 200;}
.btn {height:30px; width:850px; text-align:right;}
a {color:black; text-decoration: none; }
a:hover {font-weight: bold;}
.col1 {width:8%;}
.col2 {width:35%;}
.col3 {width:20%;}
.col4 {width:15%;}
.col5 {width:10%;}
.col6 {width:12%;}
form.js
더보기
/**
*
*/
$().ready(function(){
$("#submit11").on("click",function(){
if(validate()){
$("form").submit();
}
});
});
//chk에 대해서 점검
function validate(){
let flen = $("form[name=form1] .chk").length;
for(var i=0; i<flen; i++){
if($('.chk').eq(i).val()=="" ||
$('.chk').eq(i).val()==null||
$('.chk').eq(i).val().trim()==""){
alert($('.chk').eq(i).attr('title')+ '은/는 필수 입력');
$('.chk').eq(i).focus();
return false;
}
}
return true;
}
list.js
더보기
/**
*
*/
$().ready(function(){
let $item = $('a.content').on("click",function(){
let idx = $item.index(this);
//alert($("a.content input[type=hidden]").eq(idx).val());
var f = $('form[name=content]')
$('form input[name=bno]').attr('value', $("a.content input[name=no]").eq(idx).val());
f.attr('action','content');
f.submit();
});
})
content.js
더보기
/**
*
*/
$().ready(function(){
let f = $('form[name=form1]');
$("#update").on("click", function(){
if(checkpw()){
f.attr("action","update");
f.submit();
} else
alert("비밀번호가 틀렸습니다.");
})
$("#delete").on("click", function(){
if(checkpw()){
if(confirm("정말 삭제하시겠습니까?"))
f.attr("action","delete")
f.submit();
} else
alert("비밀번호가 틀렸습니다.");
})
$("#reply").on("click", function(){
f.attr('action','writeForm');
f.submit();
})
})
function checkpw(){
let upw = prompt("비밀번호를 입력하시오.");
let cpw = $('input[name=passwd]').val();
if(upw==cpw)
return true;
return false;
}