<c:when test="condition">
……標籤體
</c:when>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <c:set var = "hours"> <%=new java.util.Date().getHours()%> </c:set> <c:choose> <c:when test="${hours>1&&hours<=6}">早上好!</c:when> <c:when test="${hours>6&&hours<=11}">上午好!</c:when> <c:when test="${hours>11&&hours<=17}">下午好!</c:when> <c:when test="${hours>17&&hours<=24}">晚上好!</c:when> </c:choose> 現在時間是:${hours}時當11時17分時,執行上面的程式碼將顯示以下內容: