JSTL의 FN은 () 함수를 포함
FN : 포함 () 함수는 문자열이 특정 문자열이 포함되어 있는지 여부를 확인하는 데 사용됩니다.
문법
FN () 함수는 다음과 같은 구문은 포함
<c:if test="${fn:contains(<原始字符串>, <要查找的子字符串>)}"> ... </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:contains(theString, 'w3big')}"> <p>找到 w3big<p> </c:if> <c:if test="${fn:contains(theString, 'w3big')}"> <p>找到 w3big<p> </c:if> </body> </html>
결과는 다음과 같습니다 :
找到 w3big