Java Don';我不明白JSPTageException:“我不明白,我不明白。”;非法使用<;何时>-样式标记不带<;选择>;作为其直接母公司

Java Don';我不明白JSPTageException:“我不明白,我不明白。”;非法使用<;何时>-样式标记不带<;选择>;作为其直接母公司,java,jsp,jstl,nested,Java,Jsp,Jstl,Nested,我已经盯着下面嵌套的标签看了大约一个小时了,我仍然不明白为什么我一直收到一个jsptageexception: "Illegal use of <when>-style tag without <choose> as its direct parent" “非法使用-style标记而不作为其直接父项” 是否不允许在JSTL中深入嵌套条件标记 <c:choose> <c:when test="${rec.image1Available}">

我已经盯着下面嵌套的标签看了大约一个小时了,我仍然不明白为什么我一直收到一个
jsptageexception

"Illegal use of <when>-style tag without <choose> as its direct parent"
“非法使用-style标记而不作为其直接父项”
是否不允许在JSTL中深入嵌套条件标记

<c:choose>
    <c:when test="${rec.image1Available}">
    <img alt="altname" src="/img1.jpg" alt="altname" />
    <c:otherwise>
    <c:choose>
        <c:when test="${rec.image2Available}">
        <img alt="altname" src="/img2.jpg" alt="altname" />
            <c:otherwise>
            <c:choose>
                <c:when test="${rec.image3Available}">
                <img alt="altname" src="img3.jpg" alt="altname" />
                    <c:otherwise>
                    <img alt="altname" src="/holder.jpg" alt="altname" />
                    </c:otherwise>
                </c:when>
            </c:choose>
            </c:otherwise>
        </c:when>
    </c:choose>
    </c:otherwise>
    </c:when>
</c:choose>

你有
里面<代码>应按如下方式使用:

<c:choose>
    <c:when ... >
        1st alternative
    </c:when>
    <c:when ... >
        2nd alternative
    </c:when>
    ...
    <c:otherwise>
        otherwise
    </c:otherwise>
</c:choose>

第一种选择
第二种选择
...
否则
您在
标记中嵌套了
标记。这两个标签需要彼此对等。试试这个:

<c:choose>
    <c:when test="${rec.image1Available}">
        <img src="/img1.jpg" alt="altname" />
    </c:when>
    <c:otherwise>
        <c:choose>
            <c:when test="${rec.image2Available}">
                 <img src="/img2.jpg" alt="altname" />
            </c:when>
            <c:otherwise>
                <c:choose>
                    <c:when test="${rec.image3Available}">
                        <img src="img3.jpg" alt="altname" />
                    </c:when>
                    <c:otherwise>
                        <img src="/holder.jpg" alt="altname" />
                    </c:otherwise>
                </c:choose>
            </c:otherwise>
        </c:choose>
    </c:otherwise>
</c:choose>

顺便说一句:在每个
标记中,您有两个
alt
属性。我去掉了答案中多余的部分