課程
/后端開發(fā)
/Java
/JSP自定義標簽
當再次刷新jsp頁面的時候呢,這里只會取到第一個元素也就是下標為0的元素。怎么解決這個問題,我想隨便刷新幾次都可以完整的遍歷數(shù)組。就像第一次加載時一樣。
2017-10-07
源自:JSP自定義標簽 3-5
正在回答
【蜘蛛俠TG@abin789】-401【蜘蛛俠TG@abin789】-402【蜘蛛俠TG@abin789】-403【蜘蛛俠TG@abin789】-404【蜘蛛俠TG@abin789】-405【蜘蛛俠TG@abin789】-406【蜘蛛俠TG@abin789】-407【蜘蛛俠TG@abin789】-408【蜘蛛俠TG@abin789】-409【蜘蛛俠TG@abin789】-410【蜘蛛俠TG@abin789】-411【蜘蛛俠TG@abin789】-412【蜘蛛俠TG@abin789】-413【蜘蛛俠TG@abin789】-414【蜘蛛俠TG@abin789】-415【蜘蛛俠TG@abin789】-416【蜘蛛俠TG@abin789】-417【蜘蛛俠TG@abin789】-418【蜘蛛俠TG@abin789】-419【蜘蛛俠TG@abin789】-420【蜘蛛俠TG@abin789】-421【蜘蛛俠TG@abin789】-422【蜘蛛俠TG@abin789】-423【蜘蛛俠TG@abin789】-424【蜘蛛俠TG@abin789】-425【蜘蛛俠TG@abin789】-426【蜘蛛俠TG@abin789】-427【蜘蛛俠TG@abin789】-428【蜘蛛俠TG@abin789】-429【蜘蛛俠TG@abin789】-430【蜘蛛俠TG@abin789】-431【蜘蛛俠TG@abin789】-432【蜘蛛俠TG@abin789】-433【蜘蛛俠TG@abin789】-434【蜘蛛俠TG@abin789】-435【蜘蛛俠TG@abin789】-436【蜘蛛俠TG@abin789】-437【蜘蛛俠TG@abin789】-438【蜘蛛俠TG@abin789】-439【蜘蛛俠TG@abin789】-440【蜘蛛俠TG@abin789】-441【蜘蛛俠TG@abin789】-442【蜘蛛俠TG@abin789】-443【蜘蛛俠TG@abin789】-444【蜘蛛俠TG@abin789】-445【蜘蛛俠TG@abin789】-446【蜘蛛俠TG@abin789】-447【蜘蛛俠TG@abin789】-448【蜘蛛俠TG@abin789】-449【蜘蛛俠TG@abin789】-450【蜘蛛俠TG@abin789】-451【蜘蛛俠TG@abin789】-452【蜘蛛俠TG@abin789】-453【蜘蛛俠TG@abin789】-454【蜘蛛俠TG@abin789】-455【蜘蛛俠TG@abin789】-456【蜘蛛俠TG@abin789】-457【蜘蛛俠TG@abin789】-458【蜘蛛俠TG@abin789】-459【蜘蛛俠TG@abin789】-460【蜘蛛俠TG@abin789】-461【蜘蛛俠TG@abin789】-462【蜘蛛俠TG@abin789】-463【蜘蛛俠TG@abin789】-464【蜘蛛俠TG@abin789】-465【蜘蛛俠TG@abin789】-466【蜘蛛俠TG@abin789】-467【蜘蛛俠TG@abin789】-468【蜘蛛俠TG@abin789】-469【蜘蛛俠TG@abin789】-470【蜘蛛俠TG@abin789】-471【蜘蛛俠TG@abin789】-472【蜘蛛俠TG@abin789】-473【蜘蛛俠TG@abin789】-474【蜘蛛俠TG@abin789】-475【蜘蛛俠TG@abin789】-476【蜘蛛俠TG@abin789】-477【蜘蛛俠TG@abin789】-478【蜘蛛俠TG@abin789】-479【蜘蛛俠TG@abin789】-480【蜘蛛俠TG@abin789】-481【蜘蛛俠TG@abin789】-482【蜘蛛俠TG@abin789】-483【蜘蛛俠TG@abin789】-484【蜘蛛俠TG@abin789】-485【蜘蛛俠TG@abin789】-486【蜘蛛俠TG@abin789】-487【蜘蛛俠TG@abin789】-488【蜘蛛俠TG@abin789】-489【蜘蛛俠TG@abin789】-490【蜘蛛俠TG@abin789】-491【蜘蛛俠TG@abin789】-492【蜘蛛俠TG@abin789】-493【蜘蛛俠TG@abin789】-494【蜘蛛俠TG@abin789】-495【蜘蛛俠TG@abin789】-496【蜘蛛俠TG@abin789】-497【蜘蛛俠TG@abin789】-498【蜘蛛俠TG@abin789】-499【蜘蛛俠TG@abin789】-500【蜘蛛俠TG@abin789】-501【蜘蛛俠TG@abin789】-502【蜘蛛俠TG@abin789】-503【蜘蛛俠TG@abin789】-504【蜘蛛俠TG@abin789】-505【蜘蛛俠TG@abin789】-506【蜘蛛俠TG@abin789】-507【蜘蛛俠TG@abin789】-508【蜘蛛俠TG@abin789】-509【蜘蛛俠TG@abin789】-510【蜘蛛俠TG@abin789】-511【蜘蛛俠TG@abin789】-512【蜘蛛俠TG@abin789】-513【蜘蛛俠TG@abin789】-514【蜘蛛俠TG@abin789】-515【蜘蛛俠TG@abin789】-516【蜘蛛俠TG@abin789】-517【蜘蛛俠TG@abin789】-518【蜘蛛俠TG@abin789】-519【蜘蛛俠TG@abin789】-520【蜘蛛俠TG@abin789】-521【蜘蛛俠TG@abin789】-522【蜘蛛俠TG@abin789】-523【蜘蛛俠TG@abin789】-524【蜘蛛俠TG@abin789】-525【蜘蛛俠TG@abin789】-526【蜘蛛俠TG@abin789】-527【蜘蛛俠TG@abin789】-528【蜘蛛俠TG@abin789】-529【蜘蛛俠TG@abin789】-530【蜘蛛俠TG@abin789】-531【蜘蛛俠TG@abin789】-532【蜘蛛俠TG@abin789】-533【蜘蛛俠TG@abin789】-534【蜘蛛俠TG@abin789】-535【蜘蛛俠TG@abin789】-536【蜘蛛俠TG@abin789】-537【蜘蛛俠TG@abin789】-538【蜘蛛俠TG@abin789】-539【蜘蛛俠TG@abin789】-540【蜘蛛俠TG@abin789】-541【蜘蛛俠TG@abin789】-542【蜘蛛俠TG@abin789】-543【蜘蛛俠TG@abin789】-544【蜘蛛俠TG@abin789】-545【蜘蛛俠TG@abin789】-546【蜘蛛俠TG@abin789】-547【蜘蛛俠TG@abin789】-548【蜘蛛俠TG@abin789】-549【蜘蛛俠TG@abin789】-550【蜘蛛俠TG@abin789】-551【蜘蛛俠TG@abin789】-552【蜘蛛俠TG@abin789】-553【蜘蛛俠TG@abin789】-554【蜘蛛俠TG@abin789】-555【蜘蛛俠TG@abin789】-556【蜘蛛俠TG@abin789】-557【蜘蛛俠TG@abin789】-558【蜘蛛俠TG@abin789】-559【蜘蛛俠TG@abin789】-560【蜘蛛俠TG@abin789】-561【蜘蛛俠TG@abin789】-562【蜘蛛俠TG@abin789】-563【蜘蛛俠TG@abin789】-564【蜘蛛俠TG@abin789】-565【蜘蛛俠TG@abin789】-566【蜘蛛俠TG@abin789】-567【蜘蛛俠TG@abin789】-568【蜘蛛俠TG@abin789】-569【蜘蛛俠TG@abin789】-570【蜘蛛俠TG@abin789】-571【蜘蛛俠TG@abin789】-572【蜘蛛俠TG@abin789】-573【蜘蛛俠TG@abin789】-574【蜘蛛俠TG@abin789】-575【蜘蛛俠TG@abin789】-576【蜘蛛俠TG@abin789】-577【蜘蛛俠TG@abin789】-578【蜘蛛俠TG@abin789】-579【蜘蛛俠TG@abin789】-580【蜘蛛俠TG@abin789】-581【蜘蛛俠TG@abin789】-582【蜘蛛俠TG@abin789】-583【蜘蛛俠TG@abin789】-584【蜘蛛俠TG@abin789】-585【蜘蛛俠TG@abin789】-586【蜘蛛俠TG@abin789】-587【蜘蛛俠TG@abin789】-588【蜘蛛俠TG@abin789】-589【蜘蛛俠TG@abin789】-590【蜘蛛俠TG@abin789】-591【蜘蛛俠TG@abin789】-592【蜘蛛俠TG@abin789】-593【蜘蛛俠TG@abin789】-594【蜘蛛俠TG@abin789】-595【蜘蛛俠TG@abin789】-596【蜘蛛俠TG@abin789】-597【蜘蛛俠TG@abin789】-598【蜘蛛俠TG@abin789】-599【蜘蛛俠TG@abin789】-600
優(yōu)化后的IterationTag代碼:
package?Tag; import?javax.servlet.jsp.JspException; import?javax.servlet.jsp.tagext.TagSupport; public?class?IterationTag?extends?TagSupport?{ private?static?final?long?serialVersionUID?=?-5307403677622510370L; private?String?var; private?String[]?items; private?int?count; @Override public?int?doStartTag()?throws?JspException?{ if(var!=null&&items.length>0)?{// pageContext.setAttribute(var,?items[0]); count=0; return?EVAL_BODY_INCLUDE; }else?{ return?SKIP_BODY; } } @Override public?int?doAfterBody()?throws?JspException?{ if(count<items.length)?{ pageContext.setAttribute(var,?items[count]); count++; return?EVAL_BODY_AGAIN; }else?{ return?SKIP_BODY; } } public?void?setVar(String?var)?{ this.var?=?var; } public?void?setItems(String[]?items)?{ this.items?=?items; } }
可以優(yōu)化一下老師的代碼即可解決問題啦~~
標簽處理類
package jsp.lib.tag.jstl;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class ForTag extends TagSupport {
/**
*?
* <p>
* Description:
* </p>
* @author 程序員(小陳)
* @date 2018年11月24日
*/
private static final long serialVersionUID = 2563062742541978797L;
public void setVar(String var) {
this.var = var;
}
public void setDatas(String[] datas) {
this.datas = datas;
private String var;
private String[] datas;
private int index = 0;
@Override
public int doStartTag() throws JspException {
System.out.println("ForTag --- doStartTag() ");
// TODO Auto-generated method stub
index = 0;
if (var != null && datas != null) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
public int doAfterBody() throws JspException {
System.out.println("ForTag --- doAfterBody() ");
if (index < datas.length) {
pageContext.getRequest().setAttribute(var, datas[index]);
index++;
return EVAL_BODY_AGAIN;
JSP頁面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/hool" prefix="hool"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSP Tag for Use</title>
</head>
<body>
<h1>JSP Tag for Use</h1>
<%
String[] datas = { "Java", "PHP", "JSP", "Servlet", "Spring", "SQL Server", "MySQL" };
pageContext.setAttribute("datas", datas);
%>
<hool:for datas="${datas}" var="non">
<h3>
<c:out value="${non}" />
</h3>
</hool:for>
</body>
</html>
標簽庫文件:
<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>Hool</short-name>
<uri>http://java.sun.com/jsp/jstl/hool</uri>
<tag>
<name>for</name>
<tag-class>jsp.lib.tag.jstl.ForTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>var</name>
<required>true</required>
</attribute>
<name>datas</name>
<rtexprvalue>true</rtexprvalue>
</tag>
</taglib>
想new一個對象哇
有緩存
舉報
JSP自定義標簽應用,Java Web開發(fā)中一個重要的知識點
2 回答大家好,為什么tomcat對自定義標簽運用了緩存的技術,在頁面上第二次刷新的時候只輸出數(shù)組中第一個元素,其他的元素為什么沒輸出?還有什么是tomcat的緩存技術?
2 回答老師,就是7分41的時候 那個uri為什么要寫/imooc-tag,還有8分鐘的時候 第13行為什么寫成<imooc:loginDate/> 這個imooc是自定義標簽嗎? 這個loginDate是什么??? 老師我這是3個問題啊,你別只解答一個問題啊。。。。。
2 回答這個后面到底是啥?下載也沒法下載,麻煩提供下謝謝
2 回答迭代只輸出第一個值
2 回答大家好,setBodyContent(BodyContent b)到底是由JSP引擎調(diào)用的,還是由tomcat容器調(diào)用的?另外JSP引擎到底是什么?是個類嗎?JSP引擎和tomcat服務器有什么聯(lián)系?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2022-04-01
【蜘蛛俠TG@abin789】-401
【蜘蛛俠TG@abin789】-402
【蜘蛛俠TG@abin789】-403
【蜘蛛俠TG@abin789】-404
【蜘蛛俠TG@abin789】-405
【蜘蛛俠TG@abin789】-406
【蜘蛛俠TG@abin789】-407
【蜘蛛俠TG@abin789】-408
【蜘蛛俠TG@abin789】-409
【蜘蛛俠TG@abin789】-410
【蜘蛛俠TG@abin789】-411
【蜘蛛俠TG@abin789】-412
【蜘蛛俠TG@abin789】-413
【蜘蛛俠TG@abin789】-414
【蜘蛛俠TG@abin789】-415
【蜘蛛俠TG@abin789】-416
【蜘蛛俠TG@abin789】-417
【蜘蛛俠TG@abin789】-418
【蜘蛛俠TG@abin789】-419
【蜘蛛俠TG@abin789】-420
【蜘蛛俠TG@abin789】-421
【蜘蛛俠TG@abin789】-422
【蜘蛛俠TG@abin789】-423
【蜘蛛俠TG@abin789】-424
【蜘蛛俠TG@abin789】-425
【蜘蛛俠TG@abin789】-426
【蜘蛛俠TG@abin789】-427
【蜘蛛俠TG@abin789】-428
【蜘蛛俠TG@abin789】-429
【蜘蛛俠TG@abin789】-430
【蜘蛛俠TG@abin789】-431
【蜘蛛俠TG@abin789】-432
【蜘蛛俠TG@abin789】-433
【蜘蛛俠TG@abin789】-434
【蜘蛛俠TG@abin789】-435
【蜘蛛俠TG@abin789】-436
【蜘蛛俠TG@abin789】-437
【蜘蛛俠TG@abin789】-438
【蜘蛛俠TG@abin789】-439
【蜘蛛俠TG@abin789】-440
【蜘蛛俠TG@abin789】-441
【蜘蛛俠TG@abin789】-442
【蜘蛛俠TG@abin789】-443
【蜘蛛俠TG@abin789】-444
【蜘蛛俠TG@abin789】-445
【蜘蛛俠TG@abin789】-446
【蜘蛛俠TG@abin789】-447
【蜘蛛俠TG@abin789】-448
【蜘蛛俠TG@abin789】-449
【蜘蛛俠TG@abin789】-450
【蜘蛛俠TG@abin789】-451
【蜘蛛俠TG@abin789】-452
【蜘蛛俠TG@abin789】-453
【蜘蛛俠TG@abin789】-454
【蜘蛛俠TG@abin789】-455
【蜘蛛俠TG@abin789】-456
【蜘蛛俠TG@abin789】-457
【蜘蛛俠TG@abin789】-458
【蜘蛛俠TG@abin789】-459
【蜘蛛俠TG@abin789】-460
【蜘蛛俠TG@abin789】-461
【蜘蛛俠TG@abin789】-462
【蜘蛛俠TG@abin789】-463
【蜘蛛俠TG@abin789】-464
【蜘蛛俠TG@abin789】-465
【蜘蛛俠TG@abin789】-466
【蜘蛛俠TG@abin789】-467
【蜘蛛俠TG@abin789】-468
【蜘蛛俠TG@abin789】-469
【蜘蛛俠TG@abin789】-470
【蜘蛛俠TG@abin789】-471
【蜘蛛俠TG@abin789】-472
【蜘蛛俠TG@abin789】-473
【蜘蛛俠TG@abin789】-474
【蜘蛛俠TG@abin789】-475
【蜘蛛俠TG@abin789】-476
【蜘蛛俠TG@abin789】-477
【蜘蛛俠TG@abin789】-478
【蜘蛛俠TG@abin789】-479
【蜘蛛俠TG@abin789】-480
【蜘蛛俠TG@abin789】-481
【蜘蛛俠TG@abin789】-482
【蜘蛛俠TG@abin789】-483
【蜘蛛俠TG@abin789】-484
【蜘蛛俠TG@abin789】-485
【蜘蛛俠TG@abin789】-486
【蜘蛛俠TG@abin789】-487
【蜘蛛俠TG@abin789】-488
【蜘蛛俠TG@abin789】-489
【蜘蛛俠TG@abin789】-490
【蜘蛛俠TG@abin789】-491
【蜘蛛俠TG@abin789】-492
【蜘蛛俠TG@abin789】-493
【蜘蛛俠TG@abin789】-494
【蜘蛛俠TG@abin789】-495
【蜘蛛俠TG@abin789】-496
【蜘蛛俠TG@abin789】-497
【蜘蛛俠TG@abin789】-498
【蜘蛛俠TG@abin789】-499
【蜘蛛俠TG@abin789】-500
【蜘蛛俠TG@abin789】-501
【蜘蛛俠TG@abin789】-502
【蜘蛛俠TG@abin789】-503
【蜘蛛俠TG@abin789】-504
【蜘蛛俠TG@abin789】-505
【蜘蛛俠TG@abin789】-506
【蜘蛛俠TG@abin789】-507
【蜘蛛俠TG@abin789】-508
【蜘蛛俠TG@abin789】-509
【蜘蛛俠TG@abin789】-510
【蜘蛛俠TG@abin789】-511
【蜘蛛俠TG@abin789】-512
【蜘蛛俠TG@abin789】-513
【蜘蛛俠TG@abin789】-514
【蜘蛛俠TG@abin789】-515
【蜘蛛俠TG@abin789】-516
【蜘蛛俠TG@abin789】-517
【蜘蛛俠TG@abin789】-518
【蜘蛛俠TG@abin789】-519
【蜘蛛俠TG@abin789】-520
【蜘蛛俠TG@abin789】-521
【蜘蛛俠TG@abin789】-522
【蜘蛛俠TG@abin789】-523
【蜘蛛俠TG@abin789】-524
【蜘蛛俠TG@abin789】-525
【蜘蛛俠TG@abin789】-526
【蜘蛛俠TG@abin789】-527
【蜘蛛俠TG@abin789】-528
【蜘蛛俠TG@abin789】-529
【蜘蛛俠TG@abin789】-530
【蜘蛛俠TG@abin789】-531
【蜘蛛俠TG@abin789】-532
【蜘蛛俠TG@abin789】-533
【蜘蛛俠TG@abin789】-534
【蜘蛛俠TG@abin789】-535
【蜘蛛俠TG@abin789】-536
【蜘蛛俠TG@abin789】-537
【蜘蛛俠TG@abin789】-538
【蜘蛛俠TG@abin789】-539
【蜘蛛俠TG@abin789】-540
【蜘蛛俠TG@abin789】-541
【蜘蛛俠TG@abin789】-542
【蜘蛛俠TG@abin789】-543
【蜘蛛俠TG@abin789】-544
【蜘蛛俠TG@abin789】-545
【蜘蛛俠TG@abin789】-546
【蜘蛛俠TG@abin789】-547
【蜘蛛俠TG@abin789】-548
【蜘蛛俠TG@abin789】-549
【蜘蛛俠TG@abin789】-550
【蜘蛛俠TG@abin789】-551
【蜘蛛俠TG@abin789】-552
【蜘蛛俠TG@abin789】-553
【蜘蛛俠TG@abin789】-554
【蜘蛛俠TG@abin789】-555
【蜘蛛俠TG@abin789】-556
【蜘蛛俠TG@abin789】-557
【蜘蛛俠TG@abin789】-558
【蜘蛛俠TG@abin789】-559
【蜘蛛俠TG@abin789】-560
【蜘蛛俠TG@abin789】-561
【蜘蛛俠TG@abin789】-562
【蜘蛛俠TG@abin789】-563
【蜘蛛俠TG@abin789】-564
【蜘蛛俠TG@abin789】-565
【蜘蛛俠TG@abin789】-566
【蜘蛛俠TG@abin789】-567
【蜘蛛俠TG@abin789】-568
【蜘蛛俠TG@abin789】-569
【蜘蛛俠TG@abin789】-570
【蜘蛛俠TG@abin789】-571
【蜘蛛俠TG@abin789】-572
【蜘蛛俠TG@abin789】-573
【蜘蛛俠TG@abin789】-574
【蜘蛛俠TG@abin789】-575
【蜘蛛俠TG@abin789】-576
【蜘蛛俠TG@abin789】-577
【蜘蛛俠TG@abin789】-578
【蜘蛛俠TG@abin789】-579
【蜘蛛俠TG@abin789】-580
【蜘蛛俠TG@abin789】-581
【蜘蛛俠TG@abin789】-582
【蜘蛛俠TG@abin789】-583
【蜘蛛俠TG@abin789】-584
【蜘蛛俠TG@abin789】-585
【蜘蛛俠TG@abin789】-586
【蜘蛛俠TG@abin789】-587
【蜘蛛俠TG@abin789】-588
【蜘蛛俠TG@abin789】-589
【蜘蛛俠TG@abin789】-590
【蜘蛛俠TG@abin789】-591
【蜘蛛俠TG@abin789】-592
【蜘蛛俠TG@abin789】-593
【蜘蛛俠TG@abin789】-594
【蜘蛛俠TG@abin789】-595
【蜘蛛俠TG@abin789】-596
【蜘蛛俠TG@abin789】-597
【蜘蛛俠TG@abin789】-598
【蜘蛛俠TG@abin789】-599
【蜘蛛俠TG@abin789】-600
2019-08-28
優(yōu)化后的IterationTag代碼:
2018-11-24
可以優(yōu)化一下老師的代碼即可解決問題啦~~
標簽處理類
package jsp.lib.tag.jstl;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class ForTag extends TagSupport {
/**
*?
* <p>
* Description:
* </p>
*?
* @author 程序員(小陳)
*?
* @date 2018年11月24日
*?
*/
private static final long serialVersionUID = 2563062742541978797L;
public void setVar(String var) {
this.var = var;
}
public void setDatas(String[] datas) {
this.datas = datas;
}
private String var;
private String[] datas;
private int index = 0;
@Override
public int doStartTag() throws JspException {
System.out.println("ForTag --- doStartTag() ");
// TODO Auto-generated method stub
index = 0;
if (var != null && datas != null) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
}
}
@Override
public int doAfterBody() throws JspException {
System.out.println("ForTag --- doAfterBody() ");
// TODO Auto-generated method stub
if (index < datas.length) {
pageContext.getRequest().setAttribute(var, datas[index]);
index++;
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}
}
JSP頁面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/hool" prefix="hool"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSP Tag for Use</title>
</head>
<body>
<h1>JSP Tag for Use</h1>
<%
String[] datas = { "Java", "PHP", "JSP", "Servlet", "Spring", "SQL Server", "MySQL" };
pageContext.setAttribute("datas", datas);
%>
<hool:for datas="${datas}" var="non">
<h3>
<c:out value="${non}" />
</h3>
</hool:for>
</body>
</html>
標簽庫文件:
<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>Hool</short-name>
<uri>http://java.sun.com/jsp/jstl/hool</uri>
<tag>
<name>for</name>
<tag-class>jsp.lib.tag.jstl.ForTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>var</name>
<required>true</required>
</attribute>
<attribute>
<name>datas</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
2017-11-18
有緩存