English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JSTL fn:endsWith() 함수

JSP 표준 태그 라이브러리

fn:endsWith() 함수는 문자열이 지정된 접미사로 끝나는지 확인하는 데 사용됩니다.

문법

fn:endsWith() 함수의 문법은 다음과 같습니다:

<c:if test="${fn:endsWith(<원래 문자열>, <찾는 서브 문자열>)}">
...
</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 123"/>
<c:if test="${fn:endsWith(theString,123')
   <p>문자열이 123 끝<p>
</c:if>
<c:if test="${fn:endsWith(theString, 'hooo')}">
   <p>문자열이3codebox 끝<p>
</c:if>
</body>
</html>

실행 결과는 다음과 같습니다:

문자열이 123 끝

JSP 표준 태그 라이브러리