一、標籤計算表達式,只有當表達式的值爲true時,才顯示其主體內容。
二、具有以下屬性:
- 屬性 描述 必須? 默認
- 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</title>
</head>
<body>
<!-- 這裏設置了一個salary的變量 -->
<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