一:引入
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
二:if語句
1.<li>條件控制標籤:c:if</li>
<c:if test="${v1 lt v2}">
v1小於v2<br>
</c:if>
2.<li>條件控制標籤:c:choose,c:when,c:otherwise</li>
<c:choose>
<c:when test="${v1 gt v2}">
v1大於v2<br>
</c:when>
<c:otherwise>
v1小於v2<br>
</c:otherwise>
</c:choose>
3.<li>演示循環控制標籤:forEach</li>
<table border="1">
<tr>
<td>用戶名稱</td>
</tr>
<c:choose>
<c:when test="${empty users}">
<tr>
<td colspan="3">沒有符合條件的數據</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach items="${users}" var="user">
<tr>
<td>${user.username }</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>