JSP学习笔记6

Custom Tag Library

Simple Tag

javax.servlet.jsp.tagext.SimpleTag接口提供以下方法:

setJspContext() Makes the JspContext available for tag processing

setParent() Called by the web container to make the parent tag available

setJspBody() Makes the body content available for tag processing

doTag() Called by the container to begin SimpleTag operation

getParent() Called by the Java class to obtain its parent JspTag

 

javax.servlet.jsp.tagext.SimpleTagSupport类别implements SimpleTag 所有方法,并提供以下方法:

getJspContext() Returns the JspContext for processing in the tag

getJspBody() Returns the JspFragment object for body processing in the tag

findAncestorWithClass() Returns the ancestor tag with the specified class

 

javax.servlet.jsp.tagext.Tag接口提供以下方法:

void setPageContext(PageContext pc)

void setParent(Tag t)

Tag getParent()

int doStartTag() throws JspException

int doEndTag() throws JspException

void release()

javax.servlet.jsp.tagext.IterationTag接口extends Tag提供以下方法:

int doAfterBody() throws JspException

javax.servlet.jsp.tagext.BodyTag接口extends IterationTag提供以下方法:

void setBodyContent(BodyContent bc)

void doInitBody() throws JspException

javax.servlet.jsp.tagext.TagSupport类别implements IterationTag提供以下方法:

static Tag findAncestorWithClass(Tag from , java.lang.Class class)

javax.servlet.jsp.tagext.BodyTagSupport类别extends TagSupport implements BodyTag提供以下方法:

JspWriter getPreviousOut()

BodyContent getBodyContent()

===========================================================================

标签类库描述文件(Tag Library Descriptor简称TLD)

<taglib>元素定义标签类库相关信息,其子元素如下:

<tlib-version>标签库版本</tlib-version>

<jsp-version>JSP版本</jsp-version>

<short-name>定义一个简短的名称</short-name>

<uri>标签库所对应的URI信息</uri>

<tag>标签库所包含的自订标签,可定义多个

       <name>自订标签名称</name>

       <tag-class>自订标签所对应的Tag Handler Class</tag-class>

       <body-content>标签主体的种类 empty , JSP , tagdependent , scriptless</body-content>

       <description>说明</description>

       <attribute>定义属性,可定义多个

              <name>属性名称</name>

              <type>属性类型</type>

              <required>此属性是否为必要(true/false)</required>

              <rtexprvalue>属性值是否可以在JSP执行时期动态产生(true/false)</rtexprvalue>

       </attribute>

</tag>

 

 

  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章