<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!-- jstl을 이용해 대입문,제어문,서식,함수를 사용하기 위해 아래의 내용을 코딩한다. -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!-- 대입문,제어문 -->
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><!-- 서식지정 -->
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><!-- 함수 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<fmt:requestEncoding value="UTF-8"/>
<c:set var="view" value="${guestbookList.list}"/>
<table width="1000" align="center" border="1" cellpadding="5" cellspacing="0">
<tr>
<th>방명록 보기</th>
</tr>
<tr>
<td align="right">
${guestbookList.totalCount}개 (${guestbookList.currentPage}/ ${guestbookList.totalPage})Page
</td>
</tr>
<tr>
<td>
<c:if test="${view.size() == 0}">
<marquee>테이블에 글이 존재하지 않습니다.</marquee>
</c:if>
<c:if test="${view.size() != 0}">
<jsp:useBean id="date" class="java.util.Date"/>
<c:forEach var="vo" items="${view}">
<table width="99%" align="center" border="1" cellpadding="5" cellspacing="0"> <!-- 바깥표의 넓이에 99퍼 맞춘다 -->
<tr>
<td>
${vo.idx}.
<c:set var="name" value="${fn:replace(vo.name,'<','<')}"/>
<c:set var="name" value="${fn:replace(name,'>','>')}"/>
${name}님(${vo.ip}})이
<c:if test="${date.year == vo.writedate.year && date.month == vo.writedate.month && date.date == vo.writedate.date }">
<fmt:formatDate value="${vo.writedate}" pattern="HH:mm"/>
</c:if>
<c:if test="${date.year != vo.writedate.year || date.month != vo.writedate.month || date.date != vo.writedate.date }">
<fmt:formatDate value="${vo.writedate}" pattern="yyyy/MM/dd(E)"/>
</c:if>
에 남긴글
<c:set var="memo" value="${fn:replace(vo.memo,'<','<')}"/>
<c:set var="memo" value="${fn:replace(memo,'>','>')}"/>
<c:set var="memo" value="${fn:replace(memo,enter,'</br>')}"/>
${memo}
<input type="button" value="수정" onclick="location.href='selectByIdx.jsp?idx=${vo.idx}¤tPage=${guestbookList.currentPage}&job=update'"/>
<input type="button" value="삭제" onclick="location.href='selectByIdx.jsp?idx=${vo.idx}¤tPage=${guestbookList.currentPage}&job=delete'"/>
</td>
</tr>
</table>
</c:forEach>
</c:if>
</td>
</tr>
<!-- 페이지 이동 버튼 -->
<tr>
<td align="center">
<!-- 맨 앞으로 -->
<c:if test="${guestbookList.currentPage> 1}">
<input class="button button1" type="button" value="맨앞" title="첫 번째 페이지로 이동" onclick="location.href='?currentPage=1'"/>
</c:if>
<c:if test="${guestbookList.currentPage <= 1}">
<input class="button button2" type="button" value="맨앞" disabled="disabled" title="이미 첫 번째 페이지입니다."/>
</c:if>
<!-- 10페이지 앞으로 -->
<c:if test='${guestbookList.startPage>1}'>
<input class="button button1" type="button" value="이전" title="이전 10페이지로 이동" onclick="location.href='?currentPage=${guestbookList.startPage -1}'"/>
</c:if>
<c:if test='${guestbookList.startPage<=1}'>
<input class="button button2" type="button" value="이전" disabled="disabled" title="이미 첫 번째 10페이지입니다."/>
</c:if>
<!-- 페이지 이동 -->
<c:forEach var="i" begin="${guestbookList.startPage}" end="${guestbookList.endPage}">
<c:if test="${guestbookList.currentPage==i}">
<input class="button button2" type="button" value="${i}" disabled="disabled"/>
</c:if>
<c:if test="${guestbookList.currentPage!=i}">
<input class="button button1" type="button" value="${i}" onclick="location.href='?currentPage=${i}'"/>
</c:if>
</c:forEach>
<!-- 10페이지 뒤로 -->
<c:if test="${guestbookList.endPage < guestbookList.totalPage}">
<input class="button button1" type="button" value="다음" title="다음 10페이지로 이동" onclick="location.href='?currentPage=${guestbookList.endPage +1}'"/>
</c:if>
<c:if test="${guestbookList.endPage >= guestbookList.totalPage}">
<input class="button button2" type="button" value="다음" disabled="disabled" title="이미 마지막 10페이지입니다."/>
</c:if>
<!-- 맨 뒤로 -->
<c:if test="${guestbookList.currentPage < guestbookList.totalPage}">
<input class="button button1" type="button" value="맨뒤" title="마지막 페이지로 이동" onclick="location.href='?currentPage=${guestbookList.totalPage}'"/>
</c:if>
<c:if test="${guestbookList.currentPage >= guestbookList.totalPage}">
<input class="button button2" type="button" value="맨뒤" disabled="disabled" title="이미 마지막 페이지입니다."/>
</c:if>
</td>
</tr>
<!-- 글쓰기 버튼 -->
<tr>
<td align="right">
<input type="button" value="글쓰기" onclick="location.href='insert.jsp'"/>
</td>
</tr>
</table>
</body>
</html>