jstl標(biāo)簽在編程時用起來非常方便,它能為程序員在編程時提高效率,因為jstl標(biāo)簽庫是提供一系列JSP標(biāo)簽的集合,下面小編給大家具體介紹下JSTL標(biāo)簽庫及常用標(biāo)簽。
一、JSTL一共包含四大標(biāo)簽庫文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
1、core:核心標(biāo)簽庫;文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
2、fmt:格式化標(biāo)簽庫;文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
3、sql:數(shù)據(jù)庫標(biāo)簽庫;文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
4、xml:xml標(biāo)簽庫。文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
二、使用taglib指令導(dǎo)入標(biāo)簽庫文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
除了JSP動作標(biāo)簽外,使用其他第三方的標(biāo)簽庫都需要:文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
1、導(dǎo)jar包文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
2、在使用標(biāo)簽的JSP頁面中使用taglib指令導(dǎo)入標(biāo)簽庫文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
三、常用標(biāo)簽文章源自四五設(shè)計網(wǎng)-http://www.wasochina.com/33128.html
1、out和set
2、Remove
3、Url
4、if
if標(biāo)簽的test屬性必須是一個boolean類型的值,如果test的值為true,那么執(zhí)行if標(biāo)簽的內(nèi)容,否則不執(zhí)行。
5、choose
choose標(biāo)簽對應(yīng)Java中的if/else if/else結(jié)構(gòu)。when標(biāo)簽的test為true時,會執(zhí)行這個when的內(nèi)容。當(dāng)所有when標(biāo)簽的test都為false時,才會執(zhí)行otherwise標(biāo)簽的內(nèi)容。
6、forEach
forEach當(dāng)前就是循環(huán)標(biāo)簽了,forEach標(biāo)簽有多種兩種使用方式:
使用循環(huán)變量,指定開始和結(jié)束值,類似for(int i=1;i<=10;i++){};
循環(huán)遍歷集合,類似for(Object o:集合);
循環(huán)變量方式
遍歷集合或數(shù)組
遍歷List
遍歷Map
forEach標(biāo)簽還有一個屬性:varStatus,這個屬性用來指定接收“循環(huán)狀態(tài)”的變量名,例如:,這時就可以使用vs這個變量來獲取循環(huán)的狀態(tài)了。
以上就是JSTL標(biāo)簽庫及常用標(biāo)簽的介紹,它們實際操作起來并不難,而且合理使用這些jstl標(biāo)簽?zāi)軌蚩焖偻瓿蒍SP頁面的基本功能,提高編碼工作。


評論