Java Tag Library 定义tag的4种方法
Method 1(implicit TLD):
You can create a file like response.tag in WEB-INF/ tags
In response.tag you can create something like this:
<%@ attribute name="greeting" required="true" %>
<%@ attribute name="name" required="true" %>
<h2><font color="black">${greeting}, ${name}!</font></h2>
Then in the jsp file you can find the tag by adding this:
<%@ taglib tagdir="/WEB-INF/tags" prefix="h" %>
Then you can use this tag:
<h:response greeting="${greeting}" name="${param.username}"/>
Method 2:
Tag Library Descriptors
Create a file like tutorial-template.tld in WEB-INF/
Then in the jsp file you can find the tag by adding this:
<%@ taglib uri="/WEB-INF/tutorial-template.tld" prefix="tt" %>
Inside the tutorial-template.tld you need to define tags. These tags can come from a class
Method 3:
In web.xml
<taglib>
<taglib-uri>
http://jakarta.apache.org/tomcat/jsp2-example-taglib
</taglib-uri>
<taglib-location>
/WEB-INF/tags/jsp2-example-taglib.tld
</taglib-location>
</taglib>
Method 4:
To create a customized tags JAR, put the tld file into META-INF/