<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<td colspan="1" width="100">
<c:choose>
<c:when>
</c:when>
<c:when>
</c:when>
<c:when>
<c:choose>
<c:when></c:when><c:otherwise><c:when></c:when></c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
</td>
大家好,我是jsp taglibs的新手,我想知道在选择中是否有嵌套选择限制,比如这个?
编辑:JSP编译器一直在抱怨我没有结束标记,如果我把另一个标记放在其他内容。
答案 0 :(得分:4)
据我所知,有一个错误:
<c:when>
<c:choose>
<c:when></c:when><c:otherwise><c:when></c:when></c:otherwise>
</c:choose>
</c:when>
应该是:
<c:when>
<c:choose>
<c:when></c:when>
<c:otherwise></c:otherwise>
</c:choose>
</c:when>
你不能直接在内部标记嵌套,为此你需要另一个选择标记:
<c:when>
<c:choose>
<c:when></c:when>
<c:otherwise>
<c:choose>
<c:when></c:when>
</c:choose>
</c:otherwise>
</c:choose>
</c:when>
答案 1 :(得分:1)
最终你可能会用完堆栈空间。否则没有。
答案 2 :(得分:1)
常识和可读性是您可能遇到的最接近的限制。您对此代码有疑问吗?
答案 3 :(得分:1)
JSP将被转换为Java,其中将为每个自定义标记创建函数,如
private boolean _jspx_meth_c_005fwhen_005f0(javax.servlet.jsp.tagext.JspTag _jspx_th_c_005fchoose_005f0, javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// c:when
org.apache.taglibs.standard.tag.rt.core.WhenTag _jspx_th_c_005fwhen_005f0 = (org.apache.taglibs.standard.tag.rt.core.WhenTag) _005fjspx_005ftagPool_005fc_005fwhen_0026_005ftest.get(org.apache.taglibs.standard.tag.rt.core.WhenTag.class);
_jspx_th_c_005fwhen_005f0.setPageContext(_jspx_page_context);
_jspx_th_c_005fwhen_005f0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_c_005fchoose_005f0);
// /index1.jsp(4,2) name = test type = boolean reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
_jspx_th_c_005fwhen_005f0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${true}", java.lang.Boolean.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)).booleanValue());
int _jspx_eval_c_005fwhen_005f0 = _jspx_th_c_005fwhen_005f0.doStartTag();
if (_jspx_eval_c_005fwhen_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\r\n");
out.write(" ");
int evalDoAfterBody = _jspx_th_c_005fwhen_005f0.doAfterBody();
if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
break;
} while (true);
}
if (_jspx_th_c_005fwhen_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fc_005fwhen_0026_005ftest.reuse(_jspx_th_c_005fwhen_005f0);
return true;
}
_005fjspx_005ftagPool_005fc_005fwhen_0026_005ftest.reuse(_jspx_th_c_005fwhen_005f0);
return false;
}
嵌套函数会增加函数堆栈级别。默认情况下,JVM具有不错的堆栈大小,并且应该为您造成任何问题/