Reputation: 147
I used El , but it is not valid .
I get an error : javax.el.ELException: Cannot convert 1 of type class java.lang.String to class java.lang.Long
. 1 is count.
<h3>My Shopping</h3>
<c:set var="count" value=" ${sessionScope.cart.count}" />
${count}
<%--
<c:set var="cart" value="${sessionScope.cart}" />
<c:set var="count" value=" ${sessionScope.cart.count}" />
<br/>
<c:if test="${count < 1}" >
No Product in your cart
</c:if>
<c:if test="${count > 0}">
<c:set var="listCart" value="${sessionScope.cart.cart}" />
Upvotes: 2
Views: 6810
Reputation: 1108722
This exception suggests that the ${count}
is a String
, not a Long
(or Integer
, that would also work).
Provided that the count
property of the cart
bean in the session scope is already of the right type, then the only cause which I can see in the code posted so far is that there's a dangling leading space before the value.
<c:set var="count" value=" ${sessionScope.cart.count}" />
<!-- ---------------------^ -->
This effectively makes it a String
value of " 1"
which is obviously not a valid number. Removing that offending space should fix the problem.
Upvotes: 3