的FN:含有()函数确定的输入字符串是否包含指定的子串。
fn:contains()函数具有以下语法-
boolean contains(java.lang.String, java.lang.String)
以下示例说明了fn:contains()函数的功能-
<%@ 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 = "我是测试字符串"/> <c:if test = "${fn:contains(theString, 'test')}"> <p>Found test string<p> </c:if> <c:if test = "${fn:contains(theString, 'TEST')}"> <p>Found TEST string<p> </c:if> </body> </html>
您将收到以下结果-
Found test string