bbsdetail.jsp
<%@page import="dto.MemberDto"%>
<%@page import="dao.MemberDao"%>
<%@page import="java.util.List"%>
<%@page import="dao.BbsDao"%>
<%@page import="dto.BbsDto"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
MemberDto mem = (MemberDto)request.getSession().getAttribute("login");
%>
<%
String seq = request.getParameter("seq");
System.out.println(seq);
BbsDao dao = BbsDao.getInstance();
dao.readcount(Integer.parseInt(seq));
BbsDto dto = dao.getBbs(Integer.parseInt(seq));
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login하기</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="http://lab.alexcican.com/set_cookies/cookie.js" type="text/javascript" ></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
table{
border-collapse: collapse;
/* max-width: 100%; */
}
.container {
margin-left: auto;
margin-right: auto;
padding-left: 10px;
padding-right: 10px;
}
.table-header {
background-color: #95A5A6;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 0.03em;
height: 40px;
font-size: 16px;
}
.table-row {
background-color: #ffffff;
box-shadow: 0px 0px 9px 0px rgba(0,0,0,0.3);
}
.h2{
background-color: #f0f0f0;
text-align: center;
}
.wri{
text-align: right;
}
.btn {
font-size: 16px;
font-weight: bold;
background: gray;
border: none;
color: white;
border-radius: 2px;
}
</style>
</head>
<body>
<h2 class="h2">작성 글 정보</h2>
<div align="center" class="container">
<table border="1">
<tr>
<th class="table-header">작성자</th><th><%=dto.getId() %></th>
</tr>
<tr>
<th class="table-header">작성일</th><th><%=dto.getWdate() %></th>
</tr>
<tr>
<th class="table-header">조회수</th><th><%=dto.getReadcount() %></th>
</tr>
<tr >
<th class="table-header">정보</th><th><%=dto.getRef() %>-<%=dto.getStep() %>-<%=dto.getDepth() %></th>
</tr>
<tr>
<th class="table-header">제목</th><th><%=dto.getTitle() %></th>
</tr>
<tr>
<th class="table-header">내용</th><th><textarea class="form-area" id="area" name="area" cols="80" rows="30" placeholder="내용을 입력해주세요" required="required"><%=dto.getContent() %></textarea></th>
</tr>
</table>
<%
if(dto.getId().equals(mem.getId())){//작성자와 로그인id가 같을때만 수정하게해라(다를경우 수정,삭제 버튼 비공개)
%>
<button type="button" onclick="updateBbs(<%=dto.getSeq() %>)" class="btn">수정</button>
<button type="button" onclick="deleteBbs(<%=dto.getSeq() %>)" class="btn">삭제</button>
<%
}
%>
<!-- 댓글방법1 --><button type="button" onclick="answerBbs(<%=dto.getSeq()%>)" class="btn">댓글 작성하기</button>
<!-- 댓글방법2
<form action="answer.jsp" method="get">
<input type="hidden" name="seq" value="<%-- <%=bbs.getSeq()%> --%>">
<input type="submit" value="댓글">
</form>-->
</div>
<script type="text/javascript">
function updateBbs() {
location.href = "bbsupdate.jsp?seq=<%=dto.getSeq()%>";
}
function deleteBbs() {
location.href = "bbsdelete.jsp?seq=<%=dto.getSeq()%>";
}
function answerBbs() {
location.href = "answer.jsp?seq=<%=dto.getSeq()%>";
}
</script>
</body>
</html>
bbsupdate.jsp
<%@page import="dao.BbsDao"%>
<%@page import="dto.BbsDto"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
int seq = Integer.parseInt(request.getParameter("seq"));
System.out.println(seq);
BbsDao dao = BbsDao.getInstance();
BbsDto dto = dao.getBbs(seq);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
table{
border-collapse: collapse;
/* max-width: 100%; */
}
.container {
margin-left: auto;
margin-right: auto;
padding-left: 10px;
padding-right: 10px;
}
.table-header {
background-color: #95A5A6;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 0.03em;
height: 40px;
font-size: 16px;
}
.table-row {
background-color: #ffffff;
box-shadow: 0px 0px 9px 0px rgba(0,0,0,0.3);
}
.h2{
background-color: #f0f0f0;
text-align: center;
}
.wri{
text-align: right;
}
.btn {
font-size: 16px;
font-weight: bold;
background: gray;
border: none;
color: white;
border-radius: 2px;
}
</style>
</head>
<body>
<h2 class="h2">글 수정하기</h2>
<form action="bbsupdateAf.jsp" method="post">
<input type="hidden" name="seq" value="<%=dto.getSeq()%>">
<div align="center" class="container">
<table border="1">
<tr>
<th class="table-header">작성자</th><th><%=dto.getId() %></th>
</tr>
<tr>
<th class="table-header">작성일</th><th><%=dto.getWdate() %></th>
</tr>
<tr>
<th class="table-header">조회수</th><th><%=dto.getReadcount() %></th>
</tr>
<tr >
<th class="table-header">정보</th><th><%=dto.getRef() %>-<%=dto.getStep() %>-<%=dto.getDepth() %></th>
</tr>
<tr>
<th class="table-header">제목</th><th><input type="text" name="title" value="<%=dto.getTitle() %> "></th>
</tr>
<tr>
<th class="table-header">내용</th><th><textarea class="form-area" id="area" name="area" cols="80" rows="30" required="required"><%=dto.getContent() %></textarea></th>
</tr>
<tr>
<th colspan="2"><input type="submit" class="btn" value="수정하기"></th>
</tr>
</table>
</div>
</form>
</body>
</html>
BbsDao.java
//업데이트
public boolean updateBbs(int seq, String title, String content) {
String sql = " UPDATE BBS SET TITLE=? , "
+ " CONTENT=? "
+ " WHERE SEQ=? ";
Connection conn = null;
PreparedStatement psmt = null;
int count = 0;
try {
conn = DBConnection.getConnection();
System.out.println("1/6 writeBbs success");
psmt = conn.prepareStatement(sql);
psmt.setString(1, title);
psmt.setString(2, content);
psmt.setInt(3, seq);
System.out.println("2/6 writeBbs success");
count = psmt.executeUpdate();
System.out.println("3/6 writeBbs success");
} catch (Exception e) {
e.printStackTrace();
}finally {
DBClose.close(psmt, conn, null);
}
return count>0?true:false;
}
'MVC1 > 게시판' 카테고리의 다른 글
게시판// 페이징 처리 (0) | 2020.07.30 |
---|---|
게시판// select search 검색 (0) | 2020.07.30 |
게시판// 글삭제, 댓글추가, 글 detail (0) | 2020.07.29 |
게시판 list/ 글쓰기 (0) | 2020.07.28 |