锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
SKIP_PAGE
---琛ㄧず浠ヤ笅鐨勯昏緫澶勭悊閮戒笉榪愯浜?br />
SKIP_BODY
---琛ㄧず涓嶈繍琛宐ody涓殑閫昏緫澶勭悊浜?br />
EVAL_PAGE
---琛ㄧず緇х畫榪涜java涓殑閫昏緫澶勭悊
EVAL_BODY_INCLUDE
---琛ㄧず灝嗘爣絳句腑鐨刡ody鍐呭杈撳嚭鍑烘潵銆?br />
EVAL_BODY_BUFFERED
---琛ㄧず鍒涘緩浜嗕釜鏂扮殑buffer鍗矪odyContent 騫剁敱浠栨潵寮濮嬪鐞哹ody
]]>
鐨剈ri 鎵懼埌鐨?br />
uri鏄寚鍚憈ld鐨勶紝鏈変袱縐嶆柟娉曟寚鍚憈ld
涓縐嶆槸鐩存帴鎸囧悜tld鏂囦歡鎵鍦ㄧ殑浣嶇疆錛屼笌tld涓殑uri鐨勫睘鎬?lt;uri>XXXX</uri>涓鏍?br />
鍙︿竴縐嶆槸闂存帴鎸囧悜tld鏂囦歡浣嶇疆錛氫篃灝辨槸鎸囧悜涓涓?XXX錛岀劧鍚庡湪web鐨勯厤緗枃浠朵腑鎵懼埌瀵瑰簲鐨?br />
<taglib>
<taglib-uri>/XXX</taglib-uri>
<taglib-location>tld鐨勫湴鍧</taglib-location>
</taglib>
榪欎釜鏃跺欏湪tld涓氨涓嶉渶瑕佽繘琛?lt;uri>鐨勯厤緗簡
]]>
uses tags and where to find the TLD file for
the tag library or libraries it uses.
2 The JSP runtime next locates the TLD and
reads all the information about the library
from it.
3 The TLD’s information is placed in instances of the helper classes.
4 The runtime returns to reading the JSP. When it encounters a tag, it needs
to validate its usage, meaning: (1) checking if it is indeed a tag defined in
the TLD and (2) whether or not it is used properly (i.e., the tag has valid
attributes and proper body type). The TLD also informs it of the tag handler
class that implements this tag, in order for it to use that class in the
servlet being produced.
5 To validate the tag against the TLD, the runtime can make calls to the inmemory
helper objects, instead of referring to the TLD.
TLD鐨勪俊鎭姞杞藉湪TagLibraryInfo錛孴agInfo錛孴agAttributeInfo涔嬩腑
]]>
]]>
import java.io.IOException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
public class HelloWorldTag
extends TagSupport {
public int doStartTag()
throws JspException
{
try {
pageContext.getOut().print("Hello JSP tag World"); d
} catch(IOException ioe) { e
throw new JspTagException("Error:
IOException while writing to the user");
}
return SKIP_BODY;
}
}
<?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>simp</shortname>
<uri> http://www.manning.com/jsptagsbook/simple-taglib </uri>--------------榪欓噷鍙互涓嶈
<info>
A simple sample tag library
</info>
<tag>
<name>hello</name>
<tagclass>book.simpletasks.HelloWorldTag</tagclass>
<bodycontent>empty</bodycontent>
<info>
Say hello.
</info>
</tag>
</taglib>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<taglib>
<taglib-uri>
http://www.manning.com/jsptagsbook/simple-taglib
</taglib-uri>
<taglib-location>
/WEB-INF/simpletags.tld
</taglib-location>
</taglib>
</web-app>
浣跨敤鏃跺湪jsp涓姞鍏?br />
<%@ taglib
uri="http://www.manning.com/jsptagsbook/simple-taglib"
prefix="jspx" %>
娉ㄦ剰綰㈣壊鐨勯儴鍒嗚涓涓瀵瑰簲
淇濊瘉鍦╦sp欏甸潰瑁呰澆鐨勬椂鍊欐壘寰楀埌tld鏂囦歡