English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bibliothèque de balises standard JSP
La fonction fn:startsWith() est utilisée pour déterminer si une chaîne de caractères commence par un préfixe spécifié.
La syntaxe de la fonction fn:startsWith() est la suivante :
<c:if test="${fn:startsWith(<originalString>, <searchPrefix>)}"> ... </c:if>
L'exemple suivant montre la fonction de ce fichier :
<%@ 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="string" value="w3codebox: Je viens de w3codebox."/> <c:if test="${fn:startsWith(string, 'Google')}> <p>La chaîne commence par Google/p> </c:if> <br /> <c:if test="${fn:startsWith(string, 'w')}>3codebox')}> <p>La chaîne commence par w3codebox au début</p> </c:if> </body> </html>
Résultat de l'exécution suivant :
La chaîne commence par w3codebox au début