JSTL - fn:containsIgnoreCase() 函式



fn:containsIgnoreCase() 函式確定一個輸入字串是否包含一個指定的子字串。在進行搜尋時,它會忽略大小寫。

語法

fn:containsIgnoreCase() 函式有以下語法 -

boolean containsIgnoreCase(java.lang.String, java.lang.String)

示例

以下是解釋 fn:containsIgnoreCase() 函式功能的示例 -

<%@ 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"/>

      <c:if test = "${fn:containsIgnoreCase(theString, 'test')}">
         <p>Found test string<p>
      </c:if>

      <c:if test = "${fn:containsIgnoreCase(theString, 'TEST')}">
         <p>Found TEST string<p>
      </c:if>

   </body>
</html>

您將收到以下結果 -

Found test string
Found TEST string
jsp_standard_tag_library.htm
廣告
© . All rights reserved.