如何从jsp中的会话变量中删除前导零 [英] how to remove leading zeros from a session variable in jsp

查看:48
本文介绍了如何从jsp中的会话变量中删除前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个会话变量-${reData.totalCharge},它的值可能像000000033.当我在JSP中显示值时,只需要显示33即可.你怎么做到这一点 ?定义为字符串,因为数据以字符形式存储在DB2数据库中.

i have a session variable -${reData.totalCharge} it may have values like 000000033. when I display the value in JSP I need only 33 to be displayed. how do you do this ? this is defined as string as the data is stored as charecter in DB2 database.

推荐答案

Integer.parseInt(value)将起作用.但是,请在预处理代码中执行此操作,而不是在JSP中执行.另外,<fmt:formatNumber />应该可以.

Integer.parseInt(value) would work. But do that in the preprocessing code, rather than in the JSP. Also, <fmt:formatNumber /> should work.

但最终-尝试在数据库中修复此问题.您不应该将整数存储为字符串.

But ultimately - try fixing this in the database. You shouldn't be storing integers as strings.

这篇关于如何从jsp中的会话变量中删除前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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