jstl 标签
导入Jstl标签库
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
需要导入jstl.jar和standard.jar
c:forEach --> 迭代标签迭代List或Map
<c:forEach var="person" items="${list}">
${person.name }</br>
</c:forEach>
<c:foreach var="entry" items="${map }"> 对map.entrySet()返回的set集合进行迭代
${entry.key } : ${entry.value }
</c:foreach>
<c:forEach var="num" begin="1" end="9" step="1">
${num }
</c:forEach>
<!-- ${status}获取到了一个对象,这个对象包含了当前是第几次迭代 -->
<c:forEach var="str" items="${list }" varStatus="status">
<tr class="${status.count%2==0?'even':'odd'}">
</c:forEach>
c:if --> 判断标签
<c:if test="${user!=null}" var="result"> user存在的话result就为true
欢迎您:${user.username}
</c:if>
${result }
c:out
<c:out value="${data }" default="aaaaa" escapeXml="true"></c:out>
c:set
<!-- c:set可以操作各个域 javabean Map集合 -->
<c:set var="data" value="xxxxxx" scope="page"></c:set>改变data的值;
<c:set property="propertyname" value="valuexx" target="${map }"></c:set>
${map.propertyname }
<c:set property="name" value="uuuuuu" target="${person }"></c:set>
${p.name }
c:catch
<c:catch var="ex">
<%
int x = 1 / 0;
%>
</c:catch>
${ex.message }
c:forTokens --> 分割标签
<c:forTokens var="ss" items="${data1 }" delims=",">
${ss }
</c:forTokens>
data1={"a,b,c,d"}
c:url --> 生成URL
<c:url var="uurrll" value="/example/ind1ex.jsp">
<c:param name="namechina" value="中国"></c:param>
</c:url>
<a href="${uurrll }">hreftext</a>