JSTL c:if条件式で複数条件を判定するサンプル

説明
<c:if>タグには、次の属性を指定できます。
属性値 変数の有効範囲
page JSPページ
request HTTPリクエスト
session HTTPセッション
application Webアプリケーション

使用例1
書式
<c:if test="${条件式1 and 条件式2}">
処理コード
</c:if>
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<c:if test="${score>= 80 and score <= 90}">
優秀です。
</c:if>
<c:if test="${score>= 80 and score <= 90}"> 優秀です。 </c:if>
<c:if test="${score>= 80 and score <= 90}">
  優秀です。
</c:if>

使用例2
書式
<c:if test="${条件式1 or 条件式2}">
処理コード
</c:if>
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<c:if test="${score<60 and score > 90}">
要確認
</c:if>
<c:if test="${score<60 and score > 90}"> 要確認 </c:if>
<c:if test="${score<60 and score > 90}">
  要確認
</c:if>

 

JSTL

Posted by arkgame