Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用JSP标记库在choose中嵌套choose_Java_Html_Jsp - Fatal编程技术网

Java 使用JSP标记库在choose中嵌套choose

Java 使用JSP标记库在choose中嵌套choose,java,html,jsp,Java,Html,Jsp,在choose中嵌套choose是否有限制,例如: 编辑:JSP编译器不断抱怨,如果我将另一个结束标记放在另一个结束标记中,则没有结束标记。最终可能会耗尽堆栈空间。否则不会。常识和可读性是您可能遇到的最接近的限制。这段代码有什么问题吗?JSP将被翻译成Java,在Java中,将为每个自定义标记创建函数,如下所示 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <

在choose中嵌套choose是否有限制,例如:


编辑:JSP编译器不断抱怨,如果我将另一个结束标记放在另一个结束标记中,则没有结束标记。

最终可能会耗尽堆栈空间。否则不会。常识和可读性是您可能遇到的最接近的限制。这段代码有什么问题吗?

JSP将被翻译成Java,在Java中,将为每个自定义标记创建函数,如下所示

<%@ 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>

嵌套函数将增加函数堆栈级别。默认情况下,JVM具有适当的堆栈大小,据我所知,应该会给您造成任何问题。//p>有一个错误:

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;
}

应该是:

<c:when>
    <c:choose>
        <c:when></c:when><c:otherwise><c:when></c:when></c:otherwise>
    </c:choose>
</c:when>

不能将嵌套的when标记直接放在内部,否则需要另一个choose标记:

<c:when>
    <c:choose>
        <c:when></c:when>
        <c:otherwise></c:otherwise>
    </c:choose>
</c:when>


根据TLD或标签文件,标签的属性测试是强制性的。是的,是。但我只展示了标签结构的易读性。
<c:when>
    <c:choose>
        <c:when></c:when>
        <c:otherwise>
            <c:choose>
                <c:when></c:when>
            </c:choose>
        </c:otherwise>
    </c:choose>
</c:when>