当前位置: 代码迷 >> JavaScript >> JSTL瓜分字符 fn:split()
  详细解决方案

JSTL瓜分字符 fn:split()

热度:482   发布时间:2013-02-04 10:50:22.0
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>