English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The fn:join() function joins all elements of an array into a string using a specified separator.
The syntax of fn:join() function is as follows:
${fn:join([array], <delimiter>)}
The following example demonstrates the function's functionality:
<%@ 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>Using JSTL Functions</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>The string is: ${string3}<//p> </body> </html>
Note:The fn:split function returns an array of substrings split by a specified delimiter.
The running result is as follows:
The string is: www-w3codebox-com