JSTL 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 w3big"/> <c:if test="${fn:containsIgnoreCase(theString, 'w3big')}"> <p>找到 w3big<p> </c:if> <c:if test="${fn:containsIgnoreCase(theString, 'w3big')}"> <p>找到 w3big<p> </c:if> </body> </html>
ผลมีดังนี้
找到 w3big 找到 w3big