刚刚写了个简单的,呵呵。
tagtest.jsp
<%@taglib uri="http://www.cwell.com/taglibs/tagtest" prefix="tagtest"%>
<h1><tagtest:tagTest name="cwell"/></h1>TagTest.java:
package cwell;import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;public class TagTest extends TagSupport {
private String name = "";
public int doStartTag() throws JspException {
try {
JspWriter out = pageContext.getOut();
out.println("Hello," + name + ".welcome to my first tag!");
} catch(IOException ex) {
}
return SKIP_BODY;
}
public void setName(String name) { // auto call
this.name = name;
}
} // end of class TagTestweb.xml(片断):
<taglib>
<taglib-uri>http://www.cwell.com/taglibs/tagtest</taglib-uri>
<taglib-location>/WEB-INF/tagTest.tld</taglib-location>
</taglib>tagTest.tld:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"><taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>tagtest</shortname>
<uri>http://www.cwell.com/taglibs/tagtest</uri> <tag>
<name>tagTest</name>
<tagclass>cwell.TagTest</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
tagtest.jsp
<%@taglib uri="http://www.cwell.com/taglibs/tagtest" prefix="tagtest"%>
<h1><tagtest:tagTest name="cwell"/></h1>TagTest.java:
package cwell;import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;public class TagTest extends TagSupport {
private String name = "";
public int doStartTag() throws JspException {
try {
JspWriter out = pageContext.getOut();
out.println("Hello," + name + ".welcome to my first tag!");
} catch(IOException ex) {
}
return SKIP_BODY;
}
public void setName(String name) { // auto call
this.name = name;
}
} // end of class TagTestweb.xml(片断):
<taglib>
<taglib-uri>http://www.cwell.com/taglibs/tagtest</taglib-uri>
<taglib-location>/WEB-INF/tagTest.tld</taglib-location>
</taglib>tagTest.tld:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"><taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>tagtest</shortname>
<uri>http://www.cwell.com/taglibs/tagtest</uri> <tag>
<name>tagTest</name>
<tagclass>cwell.TagTest</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货