我想在我们的 jsp 页面中格式化一些数字。
首先,我在我的 porterties 中定义了一些资源
format.number.with2Decimal={0,number,#0.00}
......
问题一:
我想知道'#'和'0'是什么意思?
0.00,#0.00,##.00,###0.00
谁能告诉我它们之间的区别?谢谢!
问题2:
如果我在我的操作中定义一个 BigDecimal 类型
BigDecimal number1;
然后我的页面应该使用一种格式来显示这个值,
1.if number1=null then show -NIL-
2.if number1=0 then show -NIL-
3.if number1>0 则显示 1.00,3434.98 .....
请忽略数字<0
问题3:
将 number1 更改为字符串,
1.if number1=null or empty or blank then show -NIL-
2.if number1=Hello then show Hello ....
你能帮帮我吗?
最佳答案
给你:
<s:property value="getText('{0,number,#,##0.00}',{profit})"/>
这就是我在项目中格式化数字的方式。您可以将它与 <s:if>
一起使用达到您的要求。
关于java - 使用 Struts2 标签格式化数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20511845/