1.循环标签
<c:forEach items="${page.rows}" var="row" varStatus="status">
...
</c:forEach>
1.1.属性
属性 | 描述 | 是否必要 | 默认值 |
items | 要被循环的信息 | 否 | 无 |
begin | 开始的元素(0=第一个元素,1=第二个元素) | 否 |
end | 最后一个元素(0=第一个元素,1=第二个元素) | 否 | Last element |
step | 每一次迭代的步长 | 否 | 1 |
var | 代表当前条目的变量名称 | 否 | 无 |
varStatus | 代表循环状态的变量名称 | 否 | 无 |
1.2.例子
<tbody>
<c:forEach items="${page.rows}" var="row" varStatus="status">
<tr>
<td>${status.count}</td>
<td><a href="${pageContext.request.contextPath }/commissionsalecount/${row.cosc_id}/showpage.action">${row.cosc_code}</a></td>
<td>${row.cosc_count_start_month} - ${row.cosc_count_end_month}</td>
<td><a href="#" target="_blank" rel="external nofollow" data-toggle="modal" data-target="#customerShowDialog" οnclick= "showCustomer(${row.cosc_customer})">${row.cosc_customer_name}</a></td>
<td>${row.cosc_product_hospital}</td>
<td>${row.cosc_sale_sum_quantity}</td>
<td>${row.cosc_sale_sum_month}</td>
<td>${row.cosc_sale_sum_develop}</td>
<td>${row.cosc_sale_sum_total}</td>
<td>${row.cosc_sale_sales_names}</td>
<td>${row.cosc_sale_creater_name}</td>
<td>${row.cosc_create_date}</td>
</tr>
</c:forEach>
</tbody>
1.3.JSP页面头部引用
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
2.判断标签
<c:if test="<boolean>" var="<string>" scope="<string>">
...
</c:if>
2.1.属性
属性 | 描述 | 是否必要 | 默认值 |
test | 条件 | 是 | 无 |
var | 用于存储条件结果的变量 | 否 | 无 |
scope | var属性的作用域 | 否 | page |
2.2.例子
<c:if test="${row.cocc_applicant_id == USER_SESSION.user_id || '高级管理员' == USER_SESSION.user_authority || '管理员' == USER_SESSION.user_authority}">
<a href="${pageContext.request.contextPath }/commissioncashcount/${row.cocc_id}/editpage.action" class="btn btn-primary btn-xs">修改</a>
<a href="#" class="btn btn-danger btn-xs" onclick="deleteCommissionCashCount(${row.cocc_id})">删除</a>
</c:if>
2.3.JSP页面头部引用
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
3.判断指定变量是否包含某字符串的方法
fn:contains(指定变量,查找的字符串)
3.1.例子
<c:if test="${fn:contains(USER_SESSION.user_authority,'管理员')}">
<a href="${pageContext.request.contextPath }/commissionsalecount/examine/${row.cosc_id}/verifyshowpage.action" class="btn btn-primary btn-xs">审核</a>
</c:if>
3.2.JSP页面头部引用
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
4. 自定义i的循环
<c:forEach var="i" begin="1" end="10" step="1">
${i}
</c:forEach>