首先引入标签
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
1、if语句
<c:if test="${not empty obj.searchType and (obj.searchType==0 or searchType == 2)}">
</c:if>
2、判断是否为空
<c:if test="${not empty obj.searchType></c:if>
3、判断是否等于某个值
<c:if test="${obj.searchType==0 or searchType == 2}">
</c:if>
4、循环语句
<c:if test="${not empty types}">
<c:forEach var="obj" items="${types}">
<option value="${obj.newsTypeId}">${obj.newsTypeName}</option>
</c:forEach>
</c:if>
5、循环序号递增
<c:if test="${not empty subjectList}">
<c:set var="num" value="1"></c:set>
<c:forEach var="obj" items="${subjectList}">
<tr height="33" align="center">
<td>${num}</td>
<td align="left"><a href="" class="blue2">${obj.p_name}</a></td>
<td>${obj.p_type}</td>
<td>${obj.p_time}</td>
<td class="red1">${obj.p_negative}</td>
<td><a href="" class="blue2">详情</a></td>
</tr>
<c:set var="num" value="${num+1}"></c:set>
</c:forEach>
</c:if>
判定条件一般为一个EL表达式。
<c:if>并没有提供else子句,使用的时候可能有些不便,此时我们可以通过<c:choose>
tag来达到类似的目的:
<c:choose>
<c:when test="${var.index % 2 == 0}">
*
</c:when>
<c:otherwise>
*
</c:otherwise>
</c:choose>