<c:choose>
<c:when test="${條件}">
情況1...........
</c:when>
<c:when test="${條件}">
情況2...........
</c:when>
<c:otherwise>
否則。。。。。
</c:otherwise>
</c:choose>
jstl中if語句
<c:if>標簽計算表達式,只有當表達式的值為true,則顯示其主體內容。
屬性:
<c:if>標簽具有以下屬性:
| 屬性 | 描述 | 必需 | 默認 |
|---|---|---|---|
| test | 條件計算 | Yes | None |
| var | 變量名稱的存儲條件的結果 | No | None |
| scope | 變量的范圍的存儲條件的結果 | No | page |
例子:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example - www.yiibai.com</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
<p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>
這將產生以下結果:
My salary is: 4000
