<?xmlversion="1.0"encoding="UTF-8"?> <!DOCTYPEtaglibPUBLIC"-//SunMicrosystems,Inc.//DTDJSPTagLibrary1.1//EN""http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlib-version>1.0</tlib-version><!--标志库版本号--> <jsp-version>2.0</jsp-version><!--JSP版本--> <short-name>examples</short-name><!--taglib指令的prefix值--> <discription>Simpleexamplelibrary.</discription> <tag> <name>hello</name> <tag-class>taglib.HelloTag</tag-class> <tei-class>ProfileTagInfo</tei-class><!--该类继承了TagExtraInfo类--> <!--Thismeansthatthetagcannothavescriptingelements(〈%,〈%=,〈%!)inthebody.--> <body-content>scriptless</body-content> <discription>Firstexample</discription> <variable> <name-given>value</name-give> <!--Thismeansthattheusageofthetaginajsppagemustcontainanattributenamed"var".--> <name-from-attribute>var</name-from-attribute> <variable-class>java.lang.Double</variable-class> <scope>AT_BEGIN</scope><!--itcanbe:AT_BEGIN,AT_END,NESTED--> </variable> </tag> <tag> <name>put</name> <tag-class>taglib.template.PutTag</tag-class><!--实现了ClassicTag--> <!--3个可选值:JSP在运行期间直接计算正文;tagdependent不计算正文,并将正文传给标志解释器处理;empty正文为空--> <body-content>JSP</body-content> <discription>Secondexample.</discription> <attribute> <name>age</name> <required>true</required><!--表示该属性是强制还是可选true和yes、false和no意思一样--> <rtexprvalue>true</rtexprvalue><!--是否可以通过表达式动态求值--> <type>java.lang.Integer</type> </attribute> </tag> <tag> <name>price</name> <tag-class>com.abc.PriceTag</tag-class> <body-content>scriptless</body-content> <variable> <name-from-attribute>var</name-from-attribute> <scope>NESTED</scope> </variable> <attribute> <name>itemcode</name> <required>true</required> <rtexprvalue>false</rtexprvalue> <attribute> <tag> <!--以上的标签在JSP中表示为: <item:priceitemcode="IT001"var='cost'/> ${cost} </item:price> --> <tag> <name>functions</name> <tag-class>myTags.MathTag</tag-class><!--实现了SimpleTag--> <body-content>empty</body-content><!--beacuseJSPfragmentnotsupportscriptlets,itcannotbe"JSP"! Itcanbe:scriptless,tagdependent,empty.--> <attribute> <name>num</name> <required>true</required> <rtexprvalue>true</rtexprvalue> <fragment>true</fragment> </attribute> <dynamic-attributes>true</dynamic-attributes> <description> SendsamathexpressiontotheJSP </description> </tag> <tag-file><!--定义标签文件--> <name>tag2</name> <path>/WEB-INF/tags/HelloWorld.tag</path> </tag-file> <function><!--EL的自定义函数--> <discription>CountsthenumberofwordsinthegivenString.</discription> <name>numWords</name> <function-class>com.iee.TextEditor</function-class> <function-signature>intnumWords(java.lang.String)</function-signature> </function> </taglib>?文章出处:http://xiaoruanjian.iteye.com/blog/895301