当前页面: 开发资料首页 → JSP 专题 → 创建你的第一个自定义jsp tag(jsp标签)2
摘要: 创建你的第一个自定义jsp tag(jsp标签)2
<?xml version="1.0" encoding="ISO-8859-1" ?> taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">1.0 1.1 DemoTags http://www.stardeveloper.com Demo Tags Library firsttag com.stardeveloper.tag.test.FirstTag <bodycontent>empty</body>Your first JSP Tag name false
Tag Library Descriptor
注意:所有的内容都在和 之间,
<?xml version="1.0" encoding="ISO-8859-1" ?>
taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
提供了你的tag library 的信息,在所有的tag中几乎一样的;1.0 告示当前的tag library 版本;1.1 指明jsp版本;DemoTags 指明tag library 的名字;http://www.stardeveloper.com :没有多大的用处;
而Demo Tags Library 是一个简单的描述
现在我们看看和 的内容吧;
firsttag
com.stardeveloper.tag.test.FirstTag
<bodycontent>empty</body>
Your first JSP Tag
name
false
name是将用于jsp的前缀之前的短名,如firsttag 在
tagclass将包含完整的JSP tag class路径
bodycontent应该包含下面的其中之一:tagdependent, JSP and empty
attribute tag 描述每一个属性,在本例中required被设置为false,因此这个tag能被用而不必输入任何植.