jstl準備
1、jstl.jar和standard.jar
2、對應的tld文件
3、修改web.xml
<jsp-config>
??????? <taglib>
??????????? <taglib-uri>/WEB-INF/c.tld</taglib-uri>
??????????? <taglib-location>/WEB-INF/c.tld</taglib-location>
??????? </taglib>
??????? <jsp-property-group>
??????????? <url-pattern>*.jsp</url-pattern>
??????????? <page-encoding>UTF-8</page-encoding>
??????? </jsp-property-group>
??? </jsp-config>
<%@ taglib prefix="c" uri="
(1)表達式操作
● c:out
<c:out value="value" [escapeXml="{true|false}"] [default="defaultValue"] />
● c:set
語法1:將 value的值儲存至范圍為scope的 varName 變量之中
<c:set value="value" var="varName" [scope="{ page|request|session|application }"]/>
語法2:將本體內容的數據儲存至范圍為scope的 varName 變量之中
<c:set var="varName" [scope="{ page|request|session|application }"]>… 本體內容</c:set>
語法3:將 value的值儲存至 target 對象的屬性中
<c:set value="value" target="target" property="propertyName" />
語法4:將本體內容的數據儲存至 target 對象的屬性中
<c:set target="target" property="propertyName">… 本體內容</c:set>
● <c:remove>
<c:remove var="varName" [scope="{ page|request|session|application }"] />
?
● <c:catch>
<c:catch [var="varName"] >… 欲抓取錯誤的部分</c:catch>
?
● <c:if>
語法1:沒有本體內容(body)
<c:if test="testCondition" var="varName" [scope="{page|request|session|application}"]/>
語法2:有本體內容
<c:if test="testCondition" [var="varName"] [scope="{page|request|session|application}"]>本體內容</c:if>
?
● <c:choose>
<c:choose>
?:
?<c:when>
?</c:when>
?:
?<c:otherwise>
?</c:otherwise>
?:
</c:choose>
?
● <c:when>
<c:when test="testCondition" >本體內容</c:when>
?
● <c:otherwise>
<c:otherwise>本體內容</c:otherwise>
(2)迭代操作
● <c:forEach>
語法1:迭代一集合對象之所有成員
<c:forEach [var="varName"] items="collection" [varStatus="varStatusName"]
[begin="begin"] [end="end"] [step="step"]>
本體內容
<
/c:forEach>
語法2:迭代指定的次數
<c:forEach [var="varName"] [varStatus="varStatusName"] begin="begin" end="end" [step="step"]>
本體內容
</c:forEach>
?
(3)URL操作