fn:containsIgnoreCase()函数

约 744 字 更新于 2026-11-18 5iyo.com

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 runoob"/>



<c:if test="${fn:containsIgnoreCase(theString, 'runoob')}">

   <p>找到 runoob<p>

</c:if>



<c:if test="${fn:containsIgnoreCase(theString, 'RUNOOB')}">

     <p>找到 RUNOOB<p>

</c:if>



</body>

</html>

运行结果如下:


找到 runoob



找到 RUNOOB