- 包括兩個JAR文件,jstl.jar和standard.jar。
- 原文引入:<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core">,<%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"> ,<%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"> 。%@>%@>%@>
Core標簽庫主要包括了一般用途的標簽、條件標簽、迭代標簽和URL相關(guān)的標簽。在JSP頁面使用Core標簽,要使用taglib指令,指定引用的標簽庫如下:
<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core">
<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt">一般用途的標簽有:、、、
1.
用于計算一個表達式并將結(jié)果輸出。類似于JSP中的<%=>表達式,或者是EL中${el-expression}。
2.%=>%@>%@>%@>%@>
用于設(shè)置范圍變量的值或者JAVABEAN對象的屬性。
比如:<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=>這樣就相當于設(shè)置了session。%=>%@>%@>%@>%@>
3.
相對<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=>其作用是移除范圍變量。%=>%@>%@>%@>%@>
比如:
4.
用于捕獲在其中嵌套的操作所拋出的異常對象,并將異常信息保存到變量中。
我們將有可能拋出異常的代碼放置到開始標簽:<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=>和結(jié)束標簽:之間。如果其中代碼出現(xiàn)異常,異常對象將被捕獲,保存在var聲明的變量中,該變量總是有page范圍。如果沒有發(fā)生異常,而var所標識的范圍變量將被移除。如果沒有指定var屬性,異常只是簡單的被捕獲,異常信息并不會被保存。%=>%@>%@>%@>%@>
Eg:
<%%
int i = 5;
int j = 0;
int k = i / j;
%>
<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=><%相當于:exception.getMessage()。%%=>%@>%@>%@>%@>
條件標簽包括:<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=><%、、、%%=>%@>%@>%@>%@>
1.
用于實現(xiàn)JAVA中的if語句功能。
This is your first visit.
若為true,會打印中間部分。也可以聲明var,方便下一步判斷。
2.
<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=><%和、一起實現(xiàn)互斥條件執(zhí)行,類似于JAVA中的if else。%%=>%@>%@>%@>%@>
<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=><%一般作為、的父標簽。%%=>%@>%@>%@>%@>
Eg:
初學(xué)下海
<%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="c" taglib="" uri="http://java.sun.com/jsp/jstl/core"><%@ prefix="sql" taglib="" uri="http://java.sun.com/jsp/jstl/sql"><%@ prefix="fmt" taglib="" uri="http://java.sun.com/jsp/jstl/fmt"><%=><%row.v_money%%=>%@>%@>%@>%@> < 20000}">
身手小試
商業(yè)能手
迭代標簽:
遍歷結(jié)果集: