EL: Expression Language
JSP 2.0μμ μλ‘ μΆκ°λ μ€ν¬λ¦½νΈ μΈμ΄λ‘μ, κΈ°μ‘΄μ ννμμ λ체νλ ννμΈμ΄μ΄λ€.
μλ₯Ό λ€μ΄ sessionμ μ μ₯λμ΄ μλ μ¬μ©μ μ΄λ¦μ JSP νλ©΄μ μΆλ ₯ν λ, κΈ°μ‘΄μλ μλμ κ°μ΄ νννλ€λ©΄,
<% session.getAttrivute("userName") %>
ELμ μ΄μ©νλ©΄ μλμ κ°μ΄ ννν μ μλ€.
${userName}
μλμ μ½λμμ κ°κ°ν ${ } λ₯Ό μ΄μ©νμ¬ κ°μ μ°κ³ μλ κ²μ λ³Ό μ μλ€.
[ getBoard.jsp ]
<%@page contentType="text/html; charset=EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>κΈ μμΈ</title>
</head>
<body>
<center>
<h1>κΈ μμΈ</h1>
<a href="logout.do">Log-out</a>
<hr>
<form action="updateBoard.do" method="post">
<input name="seq" type="hidden" value="${board.seq}" />
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="orange" width="70">μ λͺ©</td>
<td align="left"><input name="title" type="text"
value="${board.title }" /></td>
</tr>
<tr>
<td bgcolor="orange">μμ±μ</td>
<td align="left">${board.writer }</td>
</tr>
<tr>
<td bgcolor="orange">λ΄μ©</td>
<td align="left"><textarea name="content" cols="40" rows="10">
${board.content }</textarea></td>
</tr>
<tr>
<td bgcolor="orange">λ±λ‘μΌ</td>
<td align="left">${board.regDate }</td>
</tr>
<tr>
<td bgcolor="orange">μ‘°νμ</td>
<td align="left">${board.cnt }</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit"
value="κΈ μμ " /></td>
</tr>
</table>
</form>
<hr>
<a href="insertBoard.jsp">κΈλ±λ‘</a>
<a href="deleteBoard.do?seq=${board.seq }">κΈμμ </a>
<a href="getBoardList.do">κΈλͺ©λ‘</a>
</center>
</body>
</html>
JSTL: JSP Standard Tag Library
JSP νλ‘κ·Έλ¨μ κ°λ°νλ€ λ³΄λ©΄ Scriptletμμ if, for, switch λ±κ³Ό κ°μ μλ° μ½λλ₯Ό μ¬μ©ν΄μΌ νλ λκ° μλ€.
JSTLμ JSPμμ μ¬μ©ν΄μΌ νλ μ΄λ° μλ° μ½λλ€μ νκ·Έ ννλ‘ μ¬μ©ν μ μλλ‘ μ§μνλ€.
μλμ μ½λμμ for 루ν λμ <c:forEach> νκ·Έλ₯Ό μ¬μ©ν κ²μ λ³Ό μ μλ€.
<c:forEach> νκ·Έλ₯Ό μ¬μ©νκΈ° μν΄ λλ²μ§Έ μ€μ taglib μ§μλ¬Έμ΄ μΆκ°λμλ€.
<%@page contentType="text/html; charset=EUC-KR"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>κΈ λͺ©λ‘</title>
</head>
<body>
<center>
<h1>κΈ λͺ©λ‘</h1>
<h3>
ν
μ€νΈλ νμν©λλ€...<a href="logout.do">Log-out</a>
</h3>
<!-- κ²μ μμ -->
<form action="getBoardList.jsp" method="post">
<table border="1" cellpadding="0" cellspacing="0" width="700">
<tr>
<td align="right"><select name="searchCondition">
<option value="TITLE">μ λͺ©
<option value="CONTENT">λ΄μ©
</select> <input name="searchKeyword" type="text" /> <input type="submit"
value="κ²μ" /></td>
</tr>
</table>
</form>
<!-- κ²μ μ’
λ£ -->
<table border="1" cellpadding="0" cellspacing="0" width="700">
<tr>
<th bgcolor="orange" width="100">λ²νΈ</th>
<th bgcolor="orange" width="200">μ λͺ©</th>
<th bgcolor="orange" width="150">μμ±μ</th>
<th bgcolor="orange" width="150">λ±λ‘μΌ</th>
<th bgcolor="orange" width="100">μ‘°νμ</th>
</tr>
<c:forEach items="${boardList }" var="board">
<tr>
<td>${board.seq }</td>
<td align="left"><a href="getBoard.do?seq=${board.seq }">
${board.title }</a></td>
<td>${board.writer }</td>
<td>${board.regDate }</td>
<td>${board.cnt }</td>
</tr>
</c:forEach>
</table>
<br> <a href="insertBoard.jsp">μκΈ λ±λ‘</a>
</center>
</body>
</html>
'Spring > Spring Quick Start' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
μ€νλ§ μΈμ½λ© μ€μ (0) | 2021.01.07 |
---|---|
WEB-INF/action-servlet.xml νμΌ μ΄λ¦ λ³κ²½νλ λ°©λ² (0) | 2021.01.07 |
Spring MVCλ₯Ό μ μ©ν κ²μν κ°λ° (0) | 2021.01.07 |
MVCλ₯Ό μ§μ ꡬννμ¬ κ²μν κ°λ° (0) | 2021.01.07 |
intelliJμμ servlet μμ±νκΈ° (0) | 2021.01.07 |
[μλ¬] intelliJ Server μ¬μ© μ outputμ°½ νκΈ κΉ¨μ§ μ€λ₯ (0) | 2021.01.07 |