我写的自定义标签的类,继承自TagSupport
jsp页里引入了2次这个标签,可类里就执行了一次构造函数,实例化了一次
自定义标签类是有属性的,如果是单例属性就乱了
请问这是怎么回事
我写的自定义标签的类,继承自TagSupport
jsp页里引入了2次这个标签,可类里就执行了一次构造函数,实例化了一次
自定义标签类是有属性的,如果是单例属性就乱了
请问这是怎么回事
你有没有看过jsp转化为的servlet。无论几个taglib,只要是相同的,最终都会转化为一个方法
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
最终在servlet只转化为了下面一个方法
[code="java"] private boolean _jspx_meth_c_005fout_005f0(PageContext _jspx_page_context)
throws Throwable {
PageContext pageContext = _jspx_page_context;
JspWriter out = _jspx_page_context.getOut();
// c:out
org.apache.taglibs.standard.tag.rt.core.OutTag _jspx_th_c_005fout_005f0 = (org.apache.taglibs.standard.tag.rt.core.OutTag) _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody.get(org.apache.taglibs.standard.tag.rt.core.OutTag.class);
_jspx_th_c_005fout_005f0.setPageContext(_jspx_page_context);
_jspx_th_c_005fout_005f0.setParent(null);
// /index.jsp(21,8) name = value type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
_jspx_th_c_005fout_005f0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.d}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
int _jspx_eval_c_005fout_005f0 = _jspx_th_c_005fout_005f0.doStartTag();
if (_jspx_th_c_005fout_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody.reuse(_jspx_th_c_005fout_005f0);
return true;
}
_005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody.reuse(_jspx_th_c_005fout_005f0);
return false;
}[/code]