[英]JSP String to Long exception
我在JSP中有如下代碼
<td class=odd
style="text-align: center"
height=30><c:if
test="${mMap['GENERAL'].errorFac != 0 and not empty mMap['GENERAL'].errorFac}">
<c:choose>
<c:when test="${mMap['GENERAL'].errorFlag == true}">
<A style="font-size:9pt" href="javascript:openWindow('${m.eTax}','${m.eDate}','GENERAL')" >
<fmt:formatNumber
value="${mMap['GENERAL'].errorFac}"
type="number" pattern="#,##0.0000" /></A>
</c:when>
<c:otherwise>
<fmt:formatNumber
value="${mMap['GENERAL'].errorFac}"
type="number" pattern="#,##0.0000" />
</c:otherwise>
</c:choose>
</c:if>
</td>
當jsp被調用時,我會感到困惑。 控制台錯誤:
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R Caused by: javax.el.ELException: Cannot convert 2.34 of type class java.lang.String to class java.lang.Long
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:497)
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:476)
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R at org.apache.el.lang.ELSupport.equals(ELSupport.java:229)
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R at org.apache.el.parser.AstNotEqual.getValue(AstNotEqual.java:39)
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37)
[5/3/17 10:13:14:025 EDT] 00000253 SystemErr R at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
值2.34是errorFac的值,它作為路徑變量出現並且是String。 我假設c:if引起了問題。 請輸入任何信息。
根據這篇文章
您需要將String與String進行比較,零是一個整數,因此:
<c:if test="${mMap['GENERAL'].errorFac != '0' and not empty mMap['GENERAL'].errorFac}">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.