JSTL標籤之標籤

一、標籤計算表達式,只有當表達式的值爲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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章