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>

 

 

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