English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função fn:endsWith() é usada para determinar se uma string termina com um sufixo específico.
A sintaxe da função fn:endsWith() é a seguinte:
<c:if test="${fn:endsWith(<string original>, <string a ser pesquisada>)}"> ... </c:if>
A seguir, um exemplo demonstra a função deste função:
<%@ 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>Usar JSTL funções</title> </head> <body> <c:set var="theString" value="I am from w3codebox 123"/> <c:if test="${fn:endsWith(theString, '123')}"> <p>String começa com 123 fim<p> </c:if> <c:if test="${fn:endsWith(theString, 'hooo')}"> <p>String começa com w3codebox fim<p> </c:if> </body> </html>
Os resultados da execução são os seguintes:
A string começa com 123 Fim