如何在jsp中将值从double转换为Integer [英] How to convert value from double to Integer in jsp

查看:236
本文介绍了如何在jsp中将值从double转换为Integer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在jsp文件中,我想显示如下计算的值:

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

<c:when test="${userProduct.term.label == 'tháng'}">
                                <c:if test="${userProduct.term.value %12==0}"> ${userProduct.term.value/12} năm</c:if>

假设该值= 36,并且我想显示给用户的数字是3.但是,我收到的数字是3.0. 目前,我正在寻找一种展示方式,正如我所期望的那样. 请告诉我知道该怎么做. 谢谢.

Supposing that value = 36 and the number which I want to show to user is 3. However, the number which I received is 3.0. Currently, I am looking for a way to show as I expected. Please tell me know the way to do it. Thanks.

推荐答案

您可以使用 fmt:parseNumber 标记

<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

这篇关于如何在jsp中将值从double转换为Integer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆