Jsp tag file例子以及说明(8)
_jspx_th_easy_005fencode_005f0.setInput("<br/> means changing line");//传入参数
_jspx_th_easy_005fencode_005f0.doTag();//调用doTag方法
_jsp_instancemanager.destroyInstance(_jspx_th_easy_005fencode_005f0);
return false;
}
例子3 在tag file中引入html和tagf文件
includeDemoTagTest.jsp
[java]
<%@ taglib prefix="easy" tagdir="/WEB-INF/tags" %>
<easy:includeDemoTag/>
includeDemoTag.tag
[java]
This tag file shows the use of the include directive.
The first include directive demonstrates how you can include
a static resource called included.html.
<br/>
Here is the content of included.html:
<%@ include file="included.html" %>
<br/>
<br/>
The second include directive includes another dynamic resource: included.tagf.
<br/>
<%@ include file="included.tagf" %>
included.tagf
[java]
<%
out.print("Hello from included.tagf");
%>
included.html
[html]
<table>
<tr>
<td><b>Menu</b></td>
</tr>
<tr>
<td>CDs</td>
</tr>
<tr>
<td>DVDs</td>
</tr>
<tr>
<td>Others</td>
</tr>
</table>
编译后的代码
includeDemoTag_tag.java
[java]
public void doTag() throws javax.servlet.jsp.JspException, java.io.IOException {
javax.servlet.jsp.PageContext _jspx_page_context = (javax.servlet.jsp.PageContext)jspContext;
javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) _jspx_page_context.getRequest();
javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse) _jspx_page_context.getResponse();
javax.servlet.http.HttpSession session = _jspx_page_context.getSession();
javax.servlet.ServletContext application = _jspx_page_context.getServletContext();
javax.servlet.ServletConfig config = _jspx_page_context.getServletConfig();
javax.servlet.jsp.JspWriter out = jspContext.getOut();
_jspInit(config);
jspContext.getELContext().putContext(javax.servlet.jsp.JspContext.class,jspContext);
try {
out.write("This tag file shows the use of the include directive. \r\n");
相关新闻>>
- 发表评论
-
- 最新评论 更多>>