How to get int type data from 6/4 in expression language
As the topic depicts, I want an integer from 6/4, but the result is 1.5(always results in double type), is there any way to get an int or change the double type into an integer,in EL?Thanks in advance.
# 1
What would you like to get for 6/4 ?1 ? 2 ?If you assign the value to an int, it will be an int.If you assign the value to a BigDecimal, it will be that.What's the problem you have got ?
# 3
My problem is, I want to get an integer(2) from 6/3, but the result is 2.0.As I know, there are no data types in EL language, so how can I get an integer(2) from that-without scriptlet in jsp page?
# 5
Yes, the way you did can generate 1.But I don't want to use scriptlet, my code is like this:<%@ taglib .....%>6/3=<c:out value="${6/3}"/>6/4=<c:out value="${6/4}"/>The result is 2.0 and 1.5.How can I get the integers without scriptlet?
# 6
I think you should check fmt.formatNumber or fmt:parseNumber
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL6.html#wp86733
http://www.java2s.com/Code/Java/JSTL/JSTLformatnumber.htm
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/formatNumber.html
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/parseNumber.html
Message was edited by:
rym82