fn:join() Function
The fn:join() function joins all elements in an array into a string using a specified delimiter.
Syntax
The syntax of the fn:join() function is as follows:
${fn:join([数组], <分隔符>)}
Example Demonstration
The following example demonstrates the functionality of this function:
<%@ 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>使用 JSTL 函数</title>
</head>
<body>
<c:set var="string1" value="www example com"/>
<c:set var="string2" value="${fn:split(string1, ' ')}" />
<c:set var="string3" value="${fn:join(string2, '-')}" />
<p>字符串为 : ${string3}</p>
</body>
</html>
Note:The fn:split function returns a string split into an array of substrings using a specified delimiter.
The output is as follows:
字符串为 : www-example-com
Other Extensions
JSP Standard Tag Library