test.jsp
[code="java"]<%@ page contentType="text/html" %>
<%@ taglib prefix="my" tagdir="/WEB-INF/tags/mytags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
${counter}: Even Row: ${anyName} |
${counter}: Odd Row: ${anyName} |
testTag.tag
[code="java"]<%@ tag body-content="empty" %>
<%@ attribute name="items" rtexprvalue="true" required="true" %>
<%@ attribute name="var" rtexprvalue="false" required="true" %>
<%@ attribute name="even" fragment="true" required="true" %>
<%@ attribute name="odd" fragment="true" required="true" %>
<%@ variable name-from-attribute="var" alias="current"
variable-class="java.lang.Object" scope="NESTED" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
/c:when
/c:otherwise
/c:choose
/c:forEach[/code]
[size=large]首先
......
二、
<%@ attribute [color=red]name="var"[/color] rtexprvalue="false" required="true" %>
在testTag.tag中这里声明了片段 var 搞不懂为什么这里的 name 还必须是 var,而此时它的值就是上面代码中的 anyName 了
三、
<%@ variable name-from-attribute=[color=red]"var"[/color] alias=[color=red]"current"[/color]
variable-class="java.lang.Object" scope="NESTED" %>
这里将名为 var 的属性的别名设置为 current , 至于 scope 关于何时将值复制到调用页面的(也就是 test.jsp 页面),什么标记开始时、什么标记结束时、在标记中时,等完全不明白,有设呢区别和,所谓的开始标记和结束标记是不是 my:testTag... /my:testTag也不清楚,愿意附带指教的请一定指教谢谢!
四、
......
这里只是声明了一个名为"current"的一个变量,它的值就是
......
这里传到片段里的值 a、b、c、d 4个
......
五、但是至于
......
上面的理解肯定有错(否则也就不会想不通了,请大家帮忙指正,谢谢!!)[/size]
${counter}: Even Row: ${[color=red]anyName[/color]} |