English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bibliothèque de balises standard JSP
La fonction fn:endsWith() est utilisée pour déterminer si une chaîne de caractères se termine par un suffixe spécifique.
La syntaxe de la fonction fn:endsWith() est la suivante :
<c:if test="${fn:endsWith(<chaîne originale>, <sous-chaîne à trouver>)}"> ... </c:if>
Voici un exemple qui montre la fonctionnalité de ce fonction :
<%@ 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>Utilisation des fonctions JSTL</title> </head> <body> <c:set var="theString" value="I am from w3codebox 123"/> <c:if test="${fn:endsWith(theString, '123')}"> <p>Une chaîne de caractères commence par 123 Fin<p> </c:if> <c:if test="${fn:endsWith(theString, 'hooo')}"> <p>Une chaîne de caractères commence par w3codebox Fin<p> </c:if> </body> </html>
Résultat de l'exécution suivant :
Une chaîne de caractères commence par 123 Fin