English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
fn:contains() 함수는 문자열이 지정된 서브 문자열을 포함하는지 확인합니다.
문법
<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 w3codebox"/> <c:if test="${fn:contains(theString, 'w3codebox')}> <p>w를 찾았습니다3codebox<p> </c:if> <c:if test="${fn:contains(theString, 'w3codebox')}> <p>w를 찾았습니다3codebox<p> </c:if> </body> </html>
실행 결과는 다음과 같습니다:
w를 찾았습니다3codebox