How to convert value from double to Integer in jsp

后端 未结 2 1695
粉色の甜心
粉色の甜心 2021-01-22 19:05

Supposing that In the jsp file, I want to show the value which is computed as below :


                     


        
相关标签:
2条回答
  • 2021-01-22 19:31

    You can use the fmt:parseNumber tag

    <c:set var="yourValue" value="${userProduct.term.value/12}" />
    <fmt:parseNumber var="intValue" integerOnly="true" 
                           type="number" value="${yourValue}" />
    

    http://www.tutorialspoint.com/jsp/jstl_format_parsenumber_tag.htm

    0 讨论(0)
  • 2021-01-22 19:38

    You could use JSTL to accomplish this, specifically the <fmt:formatNumber> tag.

    <c:if test="${userProduct.term.value %12==0}">
        <fmt:formatNumber value="${userProduct.term.value/12}"
                          maxFractionDigits="0" />
        năm
    </c:if>
    
    0 讨论(0)
提交回复
热议问题