String[] fn:split(String sourceStr, String separator)其中,sourceStr 表示源字符串,separator 为指定的分隔符。
<%@ 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"%> <!DOCTYPE html> <html> <head> <title>编程帮(www.lmcjl.com)</title> </head> <body> <c:set var="msg" value="Welcome to bianchengbang" /> <c:set var="arrayofmsg" value="${fn:split(msg,' ')}" /> <c:forEach var="i" begin="0" end="2"> arrayofmsg[${i}]: ${arrayofmsg[i]}<br> </c:forEach> </body> </html>
arrayofmsg[0]: Welcome
arrayofmsg[1]: to
arrayofmsg[2]: bianchengbang
本文链接:http://task.lmcjl.com/news/17044.html