Jsp-jstl-core-if-tag

提供:Dev Guides
移動先:案内検索

JSTL-コア<c:if>タグ

*<c:if>* タグは、式を評価し、式がtrueと評価された場合にのみその本​​文コンテンツを表示します。

属性

*<c:if>* タグには次の属性があります-
Attribute Description Required Default
test Condition to evaluate Yes None
var Name of the variable to store the condition’s result No None
scope Scope of the variable to store the condition’s result No page

<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>

<html>
   <head>
      <title><c:if> Tag Example</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