ฟังก์ชัน fn:containsIgnoreCase() ตรวจสอบว่า String มี Substring ที่ระบุหรือไม่ โดยไม่สนใจตัวพิมพ์เล็ก/ใหญ่ (Case-insensitive)
Syntax
boolean containsIgnoreCase(java.lang.String, java.lang.String)
ตัวอย่างการใช้งาน
<%@ taglib uri="https://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="https://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>พบ test string</p>
</c:if>
<c:if test="${fn:containsIgnoreCase(theString, 'TEST')}">
<p>พบ TEST string</p>
</c:if>
</body>
</html>
ผลลัพธ์
พบ test string พบ TEST string
ทั้งสองเงื่อนไขเป็น true เพราะ fn:containsIgnoreCase ไม่สนใจ Case