`

struts2 标签 (取)保留几位小数(保留2位小数、保留4位小数)、日期类型转换处理方

 
阅读更多
一、Struts2 国际化配置文件中添加如下配置:
#保留两位小数
global.format.number = {0,number,###,###0.00}
#两位小数加%
global.format.percent = {0,number,##0.00}%
global.format.money = {0,number,$##0.00} 
global.format.date = {0,date,yyyy-MM-dd}
global.format.time = {0,date,HH:mm:ss}
global.format.datetime = {0,date,yyyy-MM-dd HH:mm:ss}
#保留三位小数
global.format.number3 = {0,number,###,###0.000}
#保留四位小数
global.format.number4 = {0,number,###,###0.0000}


引用
注意:在classes下创建 config_zh_CN.properties、config_en_US.properties 两个配置文件(文件名称中“config”是可以自定义的,所以可能每个项目的名字不同,比如我的这个文件就叫做“messageResource_zh_CN.properties”,其实一个文件或更多文件也是可以的,具体的需要去料及struts2的国际化配置文件。在此不多说了。)


二、struts.xml 中引入配置文件:
<constant name="struts.custom.i18n.resources" value="config"/>

或者在struts.properties引入配置:
struts.custom.i18n.resources = config


三、页面调用
<s:text name="global.format.number"><s:param value="portfolio.others"/></s:text>
<s:text name="global.format.date"><s:param value="date"></s:param></s:text>


引用
对于日期的处理struts2提供了专门的标签:
<s:date name="collectday" format="yyyy-MM-dd"/> 
’collectday‘ 为日期对象,’yyyy-MM-dd ‘为转换成的格式
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics