2017-05-03 53 views
0

我在JSP代碼如下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被稱爲我得到FOLL。控制檯中的錯誤:

[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的值,它作爲路徑變量出現並且是字符串。我假設c:如果是造成這個問題。請輸入任何內容。

+0

[串地龍比較可能的複製拋出「ELException:不能轉換「在Tomcat 7中,在Tomcat 6中工作](http://stackoverflow.com/questions/25274458/string-to-long-comparison-throws-elexception-cannot-convert-in-tomcat-7-work) –

回答

1

基於這個帖子

String to long comparison

你需要比較串來串,零是一個整數,所以:

<c:if test="${mMap['GENERAL'].errorFac != '0' and not empty mMap['GENERAL'].errorFac}">