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=""><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=""><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=""><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=""><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> 

在这里插入图片描述

c:if test=”value ne, eq, lt, gt,….”> 用法
算术运算符 :+ 、 - 、 * 、 / (或 div )和 % (或 mod )
关系运算符 :== (或 eq )、 != (或 ne )、 < (或 lt )、 > (或 gt )、 <= (或 le )和 >= (或 ge )

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值