Why does this code generate the error “The end tag

2020-04-07 04:09发布

I don't understand why I get the error:

The end tag "</c:when" is unbalanced

when this code is run:

<c:choose>
    <c:when test="${label == 'Apple'}">
        <form:form modelAttribute="fruit" action="/fruit/${fruitId}" method="post">                 
        <form:input path="fruitId" type="hidden" value="${fruitId}"/>
    </c:when>
    <c:when test="${label == 'Orange'}">
        <form:form modelAttribute="fruit" action="/fruit/${fruitId}" method="post">
        <form:input path="fruitId" type="hidden" value="${fruitId}"/>
    </c:when>               
</c:choose>

3条回答
We Are One
2楼-- · 2020-04-07 04:51

You have an unclosed <form:form> tag.

查看更多
成全新的幸福
3楼-- · 2020-04-07 05:11

In my case I found that issue was using html comment syntax to comment out JSTL codes. Therefore recheck your html file which contains JSTL syntax to check you have done the same mistake. Please refer below example:

<!-- <security:authorize access="hasAnyRole('ASSOC_COMPANY','PUBLIC_COMPANY', 'INDIVIDUAL')"> -->

change above comment to below comment.

<%-- <security:authorize access="hasAnyRole('ASSOC_COMPANY','PUBLIC_COMPANY', 'INDIVIDUAL')"> --%>
查看更多
\"骚年 ilove
4楼-- · 2020-04-07 05:11

For me, I forgot to close a JSTL tag.

This is where should I fix

<c:set var="attendance" value="${hallManager.selectAttandanceRegisterByAttID()}" >

And after I changed to this it's fine.

<c:set var="attendance" value="${hallManager.selectAttandanceRegisterByAttID()}" />

or

<c:set var="attendance" value="${hallManager.selectAttandanceRegisterByAttID()}" ></c:set>

Some tricks to fix this problem quickly: If you have IDEs like Netbeans, please try 1.Collapse all tags and expand one by one to see which one you did not close. 2. Type " and look at the popup menu(if you have enabled it). If there is any unclosed tag it will show up.

查看更多
登录 后发表回答