English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função fn:join() une todos os elementos de um array em uma string usando um separador especificado.
A sintaxe da função fn:join() é a seguinte:
${fn:join([array], <delimitador>)}
A seguir, um exemplo demonstra a função:
<%@ 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 do JSTL</title> </head> <body> <c:set var="string1"value="www w3codebox com/> <c:set var="string2"value="${fn:split(string1, ' '}" /> <c:set var="string3"value="${fn:join(string2, '-}" /> <p>A string é: ${string3}<//p> </body> </html>
Atenção:A função fn:split retorna um array de substrings divididos por um delimitador especificado.
O resultado da execução é o seguinte:
A string é: www-w3codebox-com