fn:containsIgnoreCase()関数
fn:containsIgnoreCase()関数は、大文字と小文字を無視して、文字列が指定された部分文字列を含むかどうかを判定するために使用されます。
構文
fn:containsIgnoreCase()関数の構文は次のとおりです:
<c:if test="${fn:containsIgnoreCase(<原始字符串>, <要查找的子字符串>)}">
...
</c:if>
実例デモ
次の例は、この関数の機能を示しています:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ 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>使用 JSTL 函数</title>
</head>
<body>
<c:set var="theString" value="I am from サンプル"/>
<c:if test="${fn:containsIgnoreCase(theString, 'サンプル')}">
<p>找到 サンプル<p>
</c:if>
<c:if test="${fn:containsIgnoreCase(theString, 'サンプル')}">
<p>找到 サンプル<p>
</c:if>
</body>
</html>
実行結果は次のとおりです:
找到 サンプル 找到 サンプル
その他の拡張機能
JSP 標準タグライブラリ