1. create a tld (tag library descriptor) file namedmy-tags<code>.tld</code>. for
例如:
2. create a directory containing the compiled java tag handler class files used in your tag library.
3. create
a sub-directory of the directory you created in step 2 and call it <code>meta-inf</code>.
注意my-tag.tld必须放在meta-inf里,这也是web container回去search tld文件的位置
4. copy the <code>my-tags.tld</code> file
5. archive your compiled java class files into a <code>jar</code> file
6.copy the <code>jar</code> file
into the <code>web-inf/lib</code> directory of the web application that uses your tag library.
有些文档说需要在web.xml 中提供对tag library 的引用才可以在jsp中使用,如下:
但实际情况是,至少在tomcat 和 geronimo 服务器中,不需要上面的配置,服务器可以自己找到jar里的tld文件,可能不同的服务器其实现不一样吧。
7.reference the tag library
in your jsp. for example:
<%@ taglib prefix="r" uri="http://ebay.com/raptor"%>
<r:includeraptorjs />
参考:
<a target="_blank" href="http://docs.oracle.com/cd/e15051_01/wls/docs103/taglib/admin.html#wp364493">http://docs.oracle.com/cd/e15051_01/wls/docs103/taglib/admin.html#wp364493</a>
<a target="_blank" href="http://www.ibm.com/developerworks/cn/java/j-jsp07233/index.html">http://www.ibm.com/developerworks/cn/java/j-jsp07233/index.html</a>