English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bibliothèque de balises standard JSP
La syntaxe de la fonction fn:contains() est la suivante :
Syntaxe
<c:if test="${fn:contains(<originalString>, <substringToFind>)}"> ... </c:if>
Le suivant est un exemple qui montre la fonction de ce programme :
<%@ 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="Je viens de w3codebox"/> <c:if test="${fn:contains(theString, 'w3codebox')}> <p>Trouver w3codebox<p> </c:if> <c:if test="${fn:contains(theString, 'w3codebox')}> <p>Trouver w3codebox<p> </c:if> </body> </html>
Résultat de l'exécution suivant :
Trouver w3codebox