재밌고 어려운 IT를 이해해보자~!

VIEW에 JSTL, EL, CustomTag 사용하기 [TEAM PROJECT] 본문

코리아IT핀테크과정

VIEW에 JSTL, EL, CustomTag 사용하기 [TEAM PROJECT]

언제나즐거운IT 2024. 1. 23. 22:45

VIEW에서는 Java코드가 없어야한다!
JSTL, EL, Custom Tag를 적절히 사용하고 
Custom Tag도 JSTL을 사용해서 자바코드를 없애자.

 

Custom 태그사용하겠다 선언!

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="model.board.*,java.util.ArrayList"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="stone"%>

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>내가 작성한 게시글 목록</title>
<meta charset="utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/assets/css/main.css" />

<noscript>
	<link rel="stylesheet" href="../assets/css/noscript.css" />
</noscript>
</head>

<body class="is-preload">
	<stone:printNav member='${member}' />

	<!-- Main -->
	<div id="main">
		<!-- Featured Post -->
		<div class="table-wrapper">

			<table class="alt">
				<thead>
					<tr>
						<th>번호</th>
						<th>제목</th>
						<th>작성자</th>
						<th>날짜</th>
						<th>추천</th>
						<th>조회수</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${fn:length(boardDatas) <= 0}">
						<tr>
							<td colspan="7">내가 작성한 게시글이 없습니다.</td>
						</tr>
					</c:if>
					<c:if test="${fn:length(boardDatas) > 0}">
						<c:forEach var="data" items="${boardDatas}">
							<tr>
								<td>${data.boardNum}</td>
								<td><a
									href="myBoardSelectOnePage.do?boardNum=${data.boardNum}">${data.title}</a></td>
								<td>${data.nickname}</td>
								<td>${data.boardDate}</td>
								<td>${data.recommandCount}</td>
								<td>${data.viewCount}</td>
							</tr>
						</c:forEach>
					</c:if>
				</tbody>
			</table>
		</div>

		<!-- Footer -->
		<footer>
			<div class="pagination">
				<!--<a href="#" class="previous">Prev</a>-->
				<a href="#" class="page active">1</a> <a href="#" class="page">2</a>
				<a href="#" class="page">3</a> <span class="extra">&hellip;</span> <a
					href="#" class="page">8</a> <a href="#" class="page">9</a> <a
					href="#" class="page">10</a> <a href="#" class="next">Next</a>
			</div>
		</footer>
	</div>

	<stone:copyright />

	<!-- Scripts -->
	<script src="../assets/js/jquery.min.js"></script>
	<script src="../assets/js/jquery.scrollex.min.js"></script>
	<script src="../assets/js/jquery.scrolly.min.js"></script>
	<script src="../assets/js/browser.min.js"></script>
	<script src="../assets/js/breakpoints.min.js"></script>
	<script src="../assets/js/util.js"></script>
	<script src="../assets/js/main.js"></script>
</body>

</html>

 

Comments