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

index 본문

JSP/GuestBook

index

GAWON 2023. 6. 2. 17:58
<%@page import="org.joonzis.ex.GuestbookDao"%>
<%@page import="org.joonzis.ex.GuestbookVO"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix="c"%>     
<%
	List<GuestbookVO> list = GuestbookDao.selectAll();
	pageContext.setAttribute("list", list); //저장
%>

<!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: 100%;
		border-collapse: collapse;
	}td, th{
		border: 1px solid black;
	}thead {
		background-color: lime;
		color: #fff;
	}
	th:nth-of-type(1) {
		width: 80px;
	}
	th:nth-of-type(2) {
		width: 200px;
	}
	th:nth-of-type(3) {
		width: 300px;
	}
	th:nth-of-type(4) {
		width: 200px;
	}			

</style>
</head>
<body>
	<div>
		<h2>방명록</h2>
		<p>
			<button onclick="location.href='write_page.jsp'">글쓰기</button>
		</p>	
	<table>
		<thead>
			<tr>
				<td>번호</td>
				<td>작성자</td>
				<td>제목</td>
				<td>작성일</td>
			</tr>
		</thead>
		<tbody>
			<c:choose>
				<c:when test="${empty list }">
					<tr>
						<td colspan="4">작성된 방명록이 없습니다.</td>
				</c:when>
				<c:otherwise>
					<c:forEach var="vo" items="${list }">
						<tr>
							<td>${vo.idx }</td>
							<td>${vo.writer }</td>
							<td><a href="view.jsp?idx=${vo.idx}">${vo.title }</a></td>
							<td>${vo.reg_date }</td>
						</tr>
					</c:forEach>
				</c:otherwise>
			</c:choose>
		</tbody>			
	</table>
	</div>
</body>
</html>

'JSP > GuestBook' 카테고리의 다른 글

romove_page  (0) 2023.06.02
view  (0) 2023.06.02
download  (0) 2023.06.02
GuestbookVO  (0) 2023.06.02
GuestbookDao  (0) 2023.06.02