0

我正在使用以下代码来显示信息,但是我得到了 jstl 异常。请提出任何替代或适当的方法来处理这个

<div class="span3">
        <c:choose>
            <c:when test="${fn:length(alertStatusForm.totalSentRecipient) gt 0}">
                <div class="row-fluid"><div class="span12"><a href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalSentRecipient)}</a></div></div>  
            </c:when>
            <c:otherwise>
                        <label style="color:black"><spring:message code='alert.voice.time.others'/></label>
            </c:otherwise>
        </c:choose>
        <c:choose>
            <c:when test="${fn:length(alertStatusForm.totalNotSentRecipient) gt 0}">
                <div class="row-fluid"><div class="span12"><a style="color: red" href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalNotSentRecipient)}</a></div></div>
            </c:when>
            <c:otherwise>
                <label style="color:black"><spring:message code='alert.voice.time.others'/></label>
            </c:otherwise>
        </c:choose>
        <c:choose>
            <c:when test="${fn:length(alertStatusForm.totalInProgressRecipient) gt 0}">
                <div class="row-fluid"><div class="span12"><a href="/event/alert/recipient/list/${alertStatusForm.forAlert.id}" class="underline">${fn:length(alertStatusForm.totalInProgressRecipient)}</a></div></div>
            </c:when>
            <c:otherwise>
                        <label style="color:black"><spring:message code='alert.voice.time.others'/></label>
            </c:otherwise>
        </c:choose>
</div>
4

1 回答 1

1

我看不出这种方法有什么问题。如果您不想混合使用 html 和 jstl 代码,您仍然可以编写如下代码 -

<c:set var="html1" value="<div class='row-fluid'><div class='span12'><a href='/event/alert/recipient/list/${alertStatusForm.forAlert.id}' class='underline'>${fn:length(alertStatusForm.totalSentRecipient)}</a></div></div>" />
<c:if test="${fn:length(alertStatusForm.totalSentRecipient) lt 0}">
    <c:set var="html1" value="<label style='color:black'><spring:message code='alert.voice.time.others'/></label>" />
</c:if>

<c:set var="html2" value="<div class='row-fluid'><div class='span12'><a style='color: red' href='/event/alert/recipient/list/${alertStatusForm.forAlert.id}' class='underline'>${fn:length(alertStatusForm.totalNotSentRecipient)}</a></div></div>" />
<c:if test="${fn:length(alertStatusForm.totalNotSentRecipient) lt 0}">
    <c:set var="html2" value="<label style='color:black'><spring:message code='alert.voice.time.others'/></label>" />
</c:if>

<c:set var="html3" value="<div class='row-fluid'><div class='span12'><a href='/event/alert/recipient/list/${alertStatusForm.forAlert.id}' class='underline'>${fn:length(alertStatusForm.totalInProgressRecipient)}</a></div></div>" />
<c:if test="${fn:length(alertStatusForm.totalInProgressRecipient) lt 0}">
    <c:set var="html3" value="<label style='color:black'><spring:message code='alert.voice.time.others'/></label>" />
</c:if>

<div class="span3">
    ${html1}
    ${html2}
    ${html3}
</div>
于 2013-09-03T13:43:33.373 回答