/**
* Skip the rest of the page.
* Valid return value for doEndTag.
*/
public final static int SKIP_PAGE = 5;
/**
* Continue evaluating the page.
* Valid return value for doEndTag().
*/
public final static int EVAL_PAGE = 6;
PRivate boolean _jspx_meth_jzk_TagTest_2(PageContext _jspx_page_context)
throws Throwable {
JspWriter out = _jspx_page_context.getOut();
// jzk:TagTest
org.jzk.taglib.TagTest _jspx_th_jzk_TagTest_2 = (org.jzk.taglib.TagTest) _jspx_tagPool_jzk_TagTest_testAttr.get(org.jzk.taglib.TagTest.class);
_jspx_th_jzk_TagTest_2.setPageContext(_jspx_page_context);
_jspx_th_jzk_TagTest_2.setParent(null);
_jspx_th_jzk_TagTest_2.setTestAttr("test");
int _jspx_eval_jzk_TagTest_2 = _jspx_th_jzk_TagTest_2.doStartTag();
if (_jspx_th_jzk_TagTest_2.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
return true;
_jspx_tagPool_jzk_TagTest_testAttr.reuse(_jspx_th_jzk_TagTest_2);
return false;
}
if (_jspx_th_jzk_TagTest_2.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
return true;
private int i = 0;
public int doEndTag() throws JspException {
i++;
try {
pageContext.getResponse().getWriter().print(i + "
");
} catch (IOException e) {
//...
}
return EVAL_PAGE;
}
org.jzk.taglib.TagTest
/*
* Created on 2005-4-17
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.jzk.taglib;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
/**
* @author Jzk
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class TagTest extends TagSupport {
private String testAttr;
private int i = 0;
/*
* (non-Javadoc)
*
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doEndTag() throws JspException {
i++;
try {
pageContext.getResponse().getWriter().print(i + "
");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return EVAL_PAGE;
}
/*
* (non-Javadoc)
*
* @see javax.servlet.jsp.tagext.Tag#doStartTag()
*/
public int doStartTag() throws JspException {
try {
pageContext.getResponse().getWriter().write(testAttr);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return super.doStartTag();
}
/**
* @return Returns the testAttr.
*/
public String getTestAttr() {
return testAttr;
}
/**
* @param testAttr
* The testAttr to set.
*/
public void setTestAttr(String testAttr) {
this.testAttr = testAttr;
}
}
<?xml version="1.0" encoding="UTF-8"?>进入讨论组讨论。
<!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>bean</shortname>
<uri>jzk/tag</uri>
<tag>
<name>TagTest</name>
<tagclass>org.jzk.taglib.TagTest</tagclass>
<attribute>
<name>testAttr</name>
<required>false</required>
<rteXPrvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
(出处:http://www.VeVb.com)
新闻热点
疑难解答