English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JSTL fn:trim() função

Biblioteca de Tags Padrão JSP

fn:trim() função remove os espaços em branco nos extremos da string.

fn:trim() função de sintaxe é como follows:

Sintaxe

${fn:trim(<string>)}

Exemplo Demonstrativo

A seguir, um exemplo demonstra a função này:

<%@ 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>Usando funções JSTL</title>
</head>
<body>
<c:set var="string1" value="I am from w3codebox                         "/>
<p>${string1 Tamanho: ${fn:length(string1}<//p>
<c:set var="string2" value="${fn:trim(string1)}" />
<p>${string2 Tamanho: ${fn:length(string2}<//p>
<p>String é: ${string2}<//p>
</body>
</html>

O resultado da execução é o seguinte:

string1 Tamanho: 25
string2 Tamanho: 16
A string é: : I am from w3codebox

Biblioteca de Tags Padrão JSP