先在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})}" />
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})}" />
本文介绍如何在Struts框架中进行国际化配置,包括资源文件的创建、配置文件的设置及页面上的使用方法。通过实例展示了日期格式化、数字格式化等常见应用场景。

被折叠的 条评论
为什么被折叠?



