日期:2014-05-16  浏览次数:20398 次

JSTL分割字符 fn:split()
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
${ header['accept'] }
<c:set value="${ fn:split(header['accept'], ',') }" var="names" />
header['accept']:
<br />
<c:forEach items="${ names }" var="name">
${ name } <br />

</c:forEach>



<%
String sss="新乡,洛阳,郑州,鹤壁";
   application.setAttribute("string1",sss);
%>
<c:set value="${ fn:split(string1, ',') }" var="str1" />
<br />
<br />
<c:forEach items="${ str1 }" var="s">
${ s } <br />
</c:forEach>
</body>
</html>