天天看点

javax.el.ELException: Cannot convert false of type class java.lang.Boolean to class java.lang.Long

Stacktrace:] with root cause

javax.el.ELException: Cannot convert false of type class java.lang.Boolean to class java.lang.Long

at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:395)

at org.apache.el.lang.ELSupport.equals(ELSupport.java:177)

at org.apache.el.lang.ELSupport.compare(ELSupport.java:104)

at org.apache.el.parser.AstLessThanEqual.getValue(AstLessThanEqual.java:45)

at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)

at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944)

at

出错代码

<c:forEach items="${ddCooperations}" var="ddCooperation" varStatus="ddCooperationStatus">
	<c:if test="${ddCooperationStatus.index<=5}">
		<div class="hzjy-list wow bounceInRight animated" data-wow-delay="0.1s">
			<a href="" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" ><img src="${ddCooperation.logo}"></a>
		</div>
	</c:if>
	<c:if test="${5<ddCooperationStatus.index<=10}">
		<div class="hzjy-list  hzjy-list01 wow bounceInLeft animated" data-wow-delay="0.3s">
			<a href="" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" ><img src="${ddCooperation.logo}"></a>
		</div>
	</c:if>
	<c:if test="${10<ddCooperationStatus.index<=15}">
		<div class="hzjy-list wow bounceInRight animated" data-wow-delay="0.5s">
			<a href="" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" ><img src="${ddCooperation.logo}"></a>
		</div>
	</c:if>
	<c:if test="${15<ddCooperationStatus.index<=20}">
		<div class="hzjy-list  hzjy-list01 wow bounceInLeft animated" data-wow-delay="0.7s">
			<a href="" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" ><img src="${ddCooperation.logo}"></a>
		</div>
	</c:if>
</c:forEach>
           

原因:

jsp的EL表达式中,若用String类型的对象与数值做eq等计算时,会先将String对象转为double类型。所以当String对象含有非数字字符时会出现此异常。

方法:jsp页面上,JSTL<c:if test="">表达式出错了,把一个Long类型的数当做boolean来使用了。

我的错误原因:

<c:if test="${5<ddCooperationStatus.index<=10}"> </c:if> 不能这样使用

正确使用方法:

<c:if test="${ddCooperationStatus.index >5 && ddCooperationStatus.index <10}">	</c:if> 
           
javax.el.ELException: Cannot convert false of type class java.lang.Boolean to class java.lang.Long

c:if test=”value ne, eq, lt, gt,….”> 用法

算术运算符 :+ 、 - 、 * 、 / (或 div )和 % (或 mod )

关系运算符 :== (或 eq )、 != (或 ne )、 < (或 lt )、 > (或 gt )、 <= (或 le )和 >= (或 ge )

逻辑运算符 :&& (或 and )、 || (或 or )和 ! (或 not )

验证运算符 :empty

继续阅读