Notice
Recent Posts
Recent Comments
Link
«   2024/06   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

view.jsp 본문

JSP/JSP.sideproject

view.jsp

GAWON 2023. 6. 23. 12:49
<%@ 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>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- 전체 화면단 -->
<style type="text/css">
	div {
		width: 800px;
		margin: auto;
		text-align: center;
	}
	table {
		width: 800px;
		text-align: left;
		border-collapse: collapse;		
	}
	td,th {
		border : 1px solid green;
		padding: 10px;	
	}
	th {
		width: 130px;
		text-align: center;
		background-color: green;
		color: white;
	}
	
	#btn {
	text-align: center;
	}
	
	h1 {
		color : green;	
	}
	.insertComment th {
		border : 1px solid green;
		width: 130px;
		text-align: center;
		background-color: green;
		color: white;
	}
	.viewComment th {
		border : 1px solid green;
		width: 130px;
		text-align: center;
		background-color: green;
		color: white;
	}
	.viewComment td{
		text-align: center;
	} 
	
	.viewComment #num  {
		width:50px;
	}
	.viewComment #writer  {
		width:100px;
	}
	.viewComment #con  {
		width:250px;
	}
	.viewComment #date  {
		width:100px;
	}
	.viewComment #del  {
		width:50px;
	}
	textarea {
		resize: none;
	}
	.readonly{
		background-color: lightgray;
	}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
	function update_page(f){
		var cmd = "<input type='hidden' name='cmd' value='updatePage'/>";
		$(f).append(cmd);
		f.action = 'BBSController';
		f.submit();
	}
	function remove_page(f){
		if(confirm("해당 게시글을 삭제하시겠습니까??")){
			var cmd = "<input type='hidden' name='cmd' value='removeBBS'/>";
			$(f).append(cmd);
			f.action = 'BBSController';
			f.submit();
		}
	}
	function view_all(){
		var cp = '${currentPage}';
		location.href='BBSController?cmd=allList&currentPage=' + cp;
	}
	
	
	function insert_comment(f){
		f.action='BBSController';
		f.submit();
	}
	function remove_comment(pw, c_idx, b_idx){
		var ckPw = prompt("댓글 비밀번호를 입력하세요.");
		var cp = '${currentPage}';
		
		if(ckPw != pw){
			alert("비밀번호가 일치하지 않습니다.");
			return;
		}
		
		location.href = 'BBSController?cmd=removeComment&c_idx=' + c_idx + "&b_idx=" + b_idx + "&currentPage=" + cp;
	}
</script>
</head>
<body>
	<div>
		<h1>${bvo.b_idx }번 게시글</h1>
		<form method="post">
			<table class="bbs">
				<tbody>
					<tr>
						<th>작성자</th>
						<td>${bvo.writer }</td>
						<th>IP</th>
						<td>${bvo.ip }</td>
					</tr>
					<tr>
						<th>제목</th>
						<td colspan="3">${bvo.title }</td>
					</tr>
					<tr>
						<th>첨부파일</th>
						<td colspan="3">
							<c:choose>
								<c:when test="${bvo.filename eq null }">
									첨부파일 없음
								</c:when>
								<c:otherwise>
									<a href="bbs/download.jsp?&path=upload&filename=${bvo.filename}">${bvo.filename}</a>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
					<tr>
						<th>내용</th>
						<td colspan="3">${bvo.content }</td>
					</tr>
					<tr>
						<td colspan="4" id="btn">
							<c:if test="${bvo.writer == member.mid}">
								<input type="button" value="게시글 수정하기" onclick="update_page(this.form)">&nbsp;&nbsp;
								<input type="button" value="게시글 삭제하기" onclick="remove_page(this.form)">&nbsp;&nbsp;
							</c:if>
							<input type="button" value="목록으로 이동" onclick="view_all()">
							<input type="hidden" name="currentPage" value="${currentPage }">
							<input type="hidden" name="b_idx" value="${bvo.b_idx }">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
		
		<br/><hr/><br/>
		<!-- 댓글 입력 -->
		<form method="post">
			<table class="insertComment">
				<tbody>
					<tr>
						<th>댓글 작성자</th>
                  <td>
                     <c:if test="${not empty member }">
                        <input type="text" name="writer" value="${member.mid }" readonly class="readonly"/>
                     </c:if>
                     <c:if test="${empty member }">
                        <input type="text" name="writer" readonly class="readonly"/>
                     </c:if>
						<th>댓글 비밀번호</th>
						<td><input type="password" name="pw"></td>
					</tr>
					<tr>
						<th>댓글 내용</th>
						<td colspan="3">
							<textarea rows="3" cols="80" name="content" placeholder="댓글을 입력하세요"></textarea>
						</td>
					</tr>
					<tr>
						<td colspan="4" id="btn">
							<c:if test="${not empty member }">
								<input type="button" value="댓글 등록" onclick="insert_comment(this.form)">&nbsp;&nbsp;
								<input type="reset" value="다시 작성">
							</c:if>
							<input type="hidden" name="b_idx" value="${bvo.b_idx }">
							<input type="hidden" name="currentPage" value="${currentPage }">
							<input type="hidden" name="cmd" value="insertComment">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
		
		<br/><hr/><br/>
		<!-- 댓글 출력 -->
		<form method="post">
			<table class="viewComment">
				<thead>
					<tr>
						<th id="num">번호</th>
						<th id="writer">작성자</th>
						<th id="con">내용</th>
						<th id="date">작성일</th>
						<th id="del">삭제</th>
					</tr>
				</thead>
				<tbody>
					<c:choose>
						<c:when test="${not empty cList }">
							<c:forEach var="cvo" items="${cList }">
								<tr>
									<td>${cvo.c_idx }</td>
									<td>${cvo.writer }</td>
									<td>${cvo.content }</td>
									<td>${cvo.reg_date }</td>
									<td>
										<c:if test="${member.mid == cvo.writer }">
											<a href="javascript:remove_comment(${cvo.pw }, ${cvo.c_idx }, ${bvo.b_idx } );">삭제</a>
										</c:if>
									</td>
								</tr>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<tr>
								<td colspan="5">댓글이 없습니다.</td>
							</tr>
						</c:otherwise>
					</c:choose>
				</tbody>
			</table>
		</form>
	</div>
</body>
</html>

'JSP > JSP.sideproject' 카테고리의 다른 글

join.jsp  (0) 2023.06.23
image  (0) 2023.06.23
update.jsp  (0) 2023.06.23
update_page.jsp  (0) 2023.06.23
remove_page.jsp  (0) 2023.06.23