开发者

how to remove leading zeros from a session variable in jsp

开发者 https://www.devze.com 2023-02-06 12:27 出处:网络
i have a session variable -${reData.totalCharge} it may have values like000000033开发者_运维问答. when I display the value in JSP I need only 33 to be displayed. how do you do this ? this is defined a

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) 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消