Jsp-jstl-function-endswith

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

JSTL-fn:endsWith()関数

  • fn:endsWith()*関数は、入力文字列が指定されたサフィックスで終わるかどうかを判断します。

構文

  • fn:endsWith()*関数の構文は次のとおりです−
boolean endsWith(java.lang.String, java.lang.String)

次の例では、 fn:substring 関数の機能について説明しています-

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

<html>
   <head>
      <title>Using JSTL Functions</title>
   </head>

   <body>
      <c:set var = "theString" value = "I am a test String 123"/>

      <c:if test = "${fn:endsWith(theString, '123')}">
         <p>String ends with 123<p>
      </c:if>

      <c:if test = "${fn:endsWith(theString, 'TEST')}">
         <p>String ends with TEST<p>
      </c:if>

   </body>
</html>

次の結果が表示されます-

String ends with 123