Jsp jstl

jsp jstl使用
1.jar包引入以及页面引入
jstl-1.2.jar
页面加入<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


2.<c:forEach>的用法
items参数是遍历的对象,var是当前遍历元素
<c:forEach items="${employeeList}" var="user">
	<tr style="border: 1px solid #ccc;">
		<td align="center">${user.id}</td>
		<td align="center">${user.name}</td>
		<td align="center">
			<c:choose>
				<c:when test="${user.sex == 0}">男</c:when>   //这里的双引号是必须的
				<c:otherwise>女</c:otherwise>
			</c:choose></td>
		<td align="center"><c:out value="${user.name }"></c:out>${user.height}</td>
	</tr>
</c:forEach>




2.<c:if else>的用法,如果<c:when>中${}中的值为真,则执行(1),否则执行(2)
<c:choose>
	<c:when test="${user.sex == 0}">(1)</c:when>
	<c:otherwise>(2)</c:otherwise>
</c:choose>




3.<C:if>  如果if为真则执行,否则不执行
<c:if test="${1==1}">.....</c:if>   //这里的双引号是必须的

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325484189&siteId=291194637