JSP/MVC_BBS
allList.jsp
GAWON
2023. 6. 16. 18:13
<%@ 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;
border-collapse: collapse;
}
td, th {
border : 1px solid #1e90ff;
padding: 10px;
}
thead {
background-color: #0078ff;
color: white;
}
th:nth-of-type(1) {
width:50px;
}
th:nth-of-type(2) {
width:300px;
}
th:nth-of-type(3) {
width:100px;
}
th:nth-of-type(4) {
width:100px;
}
th:nth-of-type(5) {
width:50px;
}
h1 {
color : #0078ff;
}
a.view {
text-decoration: none;
color : black;
}
a.view:hover {
font-weight:bold;
color : tomato;
}
ul.paging {
list-style-type: none;
overflow: hidden;
margin: auto;
width:350px;
}
ul.paging li {
float: left;
margin:20px;
color: #0078ff;
}
ul.paging li a{
font-weight: bold;
display : block;
text-decoration: none;
color: #0078ff;
}
ul.paging a:hover {
background: #1e90ff;
color: white;
}
ul.paging li.disable {
color: silver;
}
ul.paging li.now{
color: tomato;
font-weight: bold;
}
tfoot tr {
margin: auto;
}
.disable {
color: silver;
}
.now{
color: tomato;
font-weight: bold;
}
.header-menu{
text-align: right;
}
.header-menu button{
text-decoration: none;
color: darkgreen;
font-weight: bold;
}
</style>
<script type="text/javascript">
function goLoginPage(){
location.href='MemController?cmd=loginPage';
}
function goJoinPage(){
location.href='MemController?cmd=joinPage';
}
function goLogout(){
location.href='MemController?cmd=logout';
}
</script>
</head>
<body>
<div class="wrap">
<div class="header-menu">
<c:if test="${not empty member }">
<button onclick="goLogout();">로그아웃</button>
</c:if>
<c:if test="${empty member }">
<button onclick="goLoginPage();">로그인</button>
</c:if>
<button onclick="goJoinPage();">회원가입</button>
</div>
<h1>BBS 게시판</h1>
<form action="/chapter20_mvc_bbs/BBSController">
<table>
<thead>
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>날짜</th>
<th>조회수</th>
</tr>
</thead>
<tbody>
<c:choose>
<c:when test="${empty list}">
<tr>
<td colspan="5">게시물이 없습니다.</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach var="vo" items="${list }">
<tr>
<td>${vo.b_idx }</td>
<td><a class="view" href="BBSController?cmd=view&b_idx=${vo.b_idx }¤tPage=${pvo.nowPage}">${vo.title }</a></td>
<td>${vo.writer }</td>
<td>${vo.reg_date }</td>
<td>${vo.hit }</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<%-- 페이징 처리예정 --%>
<%-- 1. 이전 버튼 --%>
<c:choose>
<c:when test="${pvo.beginBlock <= pvo.pagePerBlock }">
<span class ="disable"> ◀ </span>
</c:when>
<c:otherwise>
<a class="view" href="BBSController?cmd=allList¤tPage=${pvo.beginBlock - 1 }"> ◀ </a>
</c:otherwise>
</c:choose>
<%-- 2. 페이지 번호 --%>
<c:forEach var="p" begin="${pvo.beginBlock }" end="${pvo.endBlock }" step="1">
<c:choose>
<c:when test="${p eq pvo.nowPage }">
<span class="now">${p } </span>
</c:when>
<c:otherwise>
<a class="view" href="BBSController?cmd=allList¤tPage=${p}"> ${p } </a>
</c:otherwise>
</c:choose>
</c:forEach>
<%-- 3. 다음 버튼 --%>
<c:choose>
<c:when test="${pvo.endBlock >= pvo.totalPage }">
<span class ="disable"> ▶ </span>
</c:when>
<c:otherwise>
<a class="view" href="BBSController?cmd=allList¤tPage=${pvo.beginBlock + pvo.pagePerBlock }" > ▶ </a>
</c:otherwise>
</c:choose>
</td>
</tr>
</tfoot>
</table>
<p>
<input type="hidden" name="cmd" value="insert_page">
<input type="hidden" name="currentPage" value="${pvo.nowPage }">
<c:if test="${not empty member }">
<input type="submit" value="게시글 작성">
</c:if>
</p>
</form>
</div>
</body>
</html>