JSTL
1、JSTL使用步骤
- 将jstl.jar及standard.jar放至lib目录下,并add to buildpath
- 建立jsp文件,文件中引入以下语句:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
2、JSTL Core Tag Library
(1)流程控制
- <c:if>
- <c:choose>
- <c:when>
- <c:otherwise>
<c:if test="${num>0}" var="varName"/>
<h1>${varName}</h1>
<c:if test="${num>0}">
<h1>num的值为正</h1>
</c:if>
<c:if test="${num<0}">
<h1>num的值为负</h1>
</c:if>
<c:choose>
<c:when test="${num>0}">
<h1>num的值为正</h1>
</c:when>
<c:when test="${num<0}">
<h1>num的值为负</h1>
</c:when>
<c:otherwise>
<h1>num的值为0</h1>
</c:otherwise>
</c:choose>
|