我正在使用以下代码来显示信息,但是我得到了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>
答案 0 :(得分: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>