English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bibliothèque de balises standard JSP
La fonction fn:trim() supprime les espaces blancs aux extrémités de la chaîne.
Syntaxe de fn:trim()
${fn:trim(<string>)}
Voici un exemple qui montre la fonction 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="string1" value="I am from w3codebox/> <p>${string1 Longueur : ${fn:length(string1}<//p> <c:set var="string2" value="${fn:trim(string1)" /> <p>${string2 Longueur : ${fn:length(string2}<//p> <p>La chaîne est : ${string2}<//p> </body> </html>
Les résultats du fonctionnement sont les suivants :
string1 Longueur : 25 string2 Longueur : 16 La chaîne est : : I am from w3codebox