提供 if choose forEach 等结构语句
语句中靠el表达式
JSP Standard Tag Library
使用位置 :jsp
JSTL依赖el表达式取值
是第三方库,要导入jar
<c:forEach var="user" items="${pageScope.users }" varStatus="vs">
<c:forEach var="i" begin="1" end="10" step="2" varStatus="vs">
<c:if test="${!empty user }" var="result" scope="page">
<c:if test="${!item.child&&!item.lady}">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:forEach var="item" items="${tourist}">
<c:if test="${item.child}">
{label: "${item.name}<span class='myTag tagChild'>不适合小孩</span>", value: "${item.name}", disable: false},
</c:if>
<c:if test="${item.lady}">
{label: "${item.name}<span class='myTag tagLady'>不适合老人</span>", value: "${item.name}", disable: false},
</c:if>
<c:if test="${item.child&&item.lady}">
{
label: "${item.name}<span class='myTag tagChild'>不适合小孩</span><span class='myTag tagLady'>不适合老人</span>",
value: "${item.name}",
disable: false
},
</c:if>
<c:if test="${!item.child&&!item.lady}">
{label: "${item.name}", value: "${item.name}", disable: false},
</c:if>
</c:forEach>
<%
User u = new User();
u.setUsername("rose");
u.setAge(10);
//pageContext.setAttribute("user", u);
if(pageContext.getAttribute("user") != null){
%>
<h2>${pageScope.user.username}</h2>
<%
}else{
%>
<h2>亲,请登录</h2>
<%
}
%>
<c:set var="username" value="rose" scope="page"></c:set>
<c:out value="${pageScope.username}" default="默认值"></c:out>
<c:out value="<a href='http://www.baidu.com'>去百度</a>" escapeXml="false"></c:out>
<c:remove var="username"/>
<c:if test="${!empty user }" var="result" scope="page">
${user.username } ${result }
</c:if>
<c:choose>
<c:when test="${empty user }">
<h2>请登录</h2>
</c:when>
<c:otherwise>
${user.username }
</c:otherwise>
</c:choose>
<c:forEach var="i" begin="1" end="10" step="2" varStatus="vs">
${i } ${vs.count } ${vs.index } ${vs.first } ${vs.last } ${vs.current }
<br/>
</c:forEach>
<c:forEach var="m" items="${cps }">
${m.key }---${m.value }
</c:forEach>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<th>用户id</th>
<th>用户名</th>
<th>用户密码</th>
<th>用户生日</th>
<th>操作</th>
</tr>
<c:forEach var="user" items="${pageScope.users }" varStatus="vs">
<tr>
<td>
${user.id }
</td>
<td>
${user.name }
</td>
<td>
${user.password }
</td>
<td>
${ user.birthday }
</td>
<td>
${vs.index } ${vs.current } ${vs.count }
<a href="${pageContext.request.contextPath}/user?id=${user.id}&method=delete">删除</a>
<a href="${pageContext.request.contextPath }/user?id=${user.id}&method=update">修改</a>
</td>
</tr>
</c:forEach>
</table>
评论区