JSP String to Long 异常
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 的值,是一个字符串。我假设 c:if 是导致问题的原因。请输入任何信息。
基于此post
String to long comparison
您需要将字符串与字符串进行比较,零是一个整数,因此:
<c:if test="${mMap['GENERAL'].errorFac != '0' and not empty mMap['GENERAL'].errorFac}">
我在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 的值,是一个字符串。我假设 c:if 是导致问题的原因。请输入任何信息。
基于此post
String to long comparison
您需要将字符串与字符串进行比较,零是一个整数,因此:
<c:if test="${mMap['GENERAL'].errorFac != '0' and not empty mMap['GENERAL'].errorFac}">