strus2格式化数字和日期(转)

strus2格式化数字和日期

文章分类:Java编程
先在class目录下建资源文件(根据实际情况加相应内容)如:applicationResource_zh_CN.properties中
format.number.money = {0,number,###,###.00}
global.format.datetime = {0, date, yyyy-MM-dd HH:mm:ss}
global.format.date = {0, date, yyyy-MM-dd}

struts.xml中加上
<constant name="struts.custom.i18n.resources" value="applicationResource"></constant>

页面上用
<s:text name="format.number.money">
   <s:param value="值"/>
</s:text>

<s:text name="global.format.datetime">
   <s:param value="obj.sj"/>
</s:text>

其它方法
<s:date name="#request.time" format="yyyy-MM-dd"/>

<input type="text" name="time1" value="<s:date format="yyyy-MM-dd" name="#request.time"/>">

<s:textfield name="#request.sys.time" >
        <s:param name="value"><s:date name="#request.time" format="yyyy-MM-dd"/></s:param>
</s:textfield>

<s:textfield name="time" value="%{getText('global.format.date',{#request.time})}" />

原文地址:https://www.cnblogs.com/wishma/p/1920565.html