Struts2 的国际化&格式化数据
2011-10-11 11:29
260 查看
国际化的作用就是根据不同国家的用户在访问Web或其他类型的程序时,将各种信息以本地的常用形式显示出来,如界面信息在中国,就会显示中文信息,在以英文为主的国家里,就会显示英文信息。还有就是一些信息的格式,如日期格式等。
1、在SRC下建立 struts.properties 文件、globalMessages_en_US.properties文件和globalMessages_zh_CN.properties 文件
2、修改文件内容struts.properties 文件 中加入以下代码:
struts.custom.i18n.resources=globalMessages以下建立的语言包都以globalMessages开头命名。
定义英文语言包,在globalMessages_en_US.properties 文件中加入以下代码:
#number:
global.format.money={0,number,#0.00##}
global.format.money02={0,number,##0.00}
#datetime:
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.datetime02={0,date,yyyy-MM-dd HH:mm}
页面上:<s:text name="global.format.date"><s:param value="deployDate" /></s:text>
其中:<s:text name="global.format.date">控制你要显示的时间格式
<s:param value="deployDate" />是你要显示的时间
JSP文件
格式化时间: <s:text name="global.format.date"><s:param value="publishTime"></s:param></s:text>
格式化数字: <s:text name="global.format.money"><s:param value="price"/></s:text>
二:
<input type="text" value="<s:date name="deployDate" format="yyyy-MM-dd" />" />
其中name="deployDate"是你要显示的时间,format="yyyy-MM-dd"是显示的格式
如果不喜欢使用标签的方式,还可以用如下方式取值。,本人更喜欢如下方式,如:
<s:property value="%{getText('global.format.money',{#session.order.productNum})}" />
FROM: http://www.iteye.com/topic/965840
简单案例:http://blog.csdn.net/houqj/article/details/4393132
JSP之数据格式化: http://www.jspcn.net/htmlnews/11500636532961641.html
1、在SRC下建立 struts.properties 文件、globalMessages_en_US.properties文件和globalMessages_zh_CN.properties 文件
2、修改文件内容struts.properties 文件 中加入以下代码:
struts.custom.i18n.resources=globalMessages以下建立的语言包都以globalMessages开头命名。
定义英文语言包,在globalMessages_en_US.properties 文件中加入以下代码:
#number:
global.format.money={0,number,#0.00##}
global.format.money02={0,number,##0.00}
#datetime:
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.datetime02={0,date,yyyy-MM-dd HH:mm}
页面上:<s:text name="global.format.date"><s:param value="deployDate" /></s:text>
其中:<s:text name="global.format.date">控制你要显示的时间格式
<s:param value="deployDate" />是你要显示的时间
JSP文件
格式化时间: <s:text name="global.format.date"><s:param value="publishTime"></s:param></s:text>
格式化数字: <s:text name="global.format.money"><s:param value="price"/></s:text>
二:
<input type="text" value="<s:date name="deployDate" format="yyyy-MM-dd" />" />
其中name="deployDate"是你要显示的时间,format="yyyy-MM-dd"是显示的格式
如果不喜欢使用标签的方式,还可以用如下方式取值。,本人更喜欢如下方式,如:
<s:property value="%{getText('global.format.money',{#session.order.productNum})}" />
FROM: http://www.iteye.com/topic/965840
简单案例:http://blog.csdn.net/houqj/article/details/4393132
JSP之数据格式化: http://www.jspcn.net/htmlnews/11500636532961641.html
相关文章推荐
- c#List泛型数据扩展,把List<>型数据格式化成List<SelectListItem>,用来作dropdownlist的数据
- Struts2 返回 json 的数组数据为 "空" 的解决方案
- highcharts 图表插件与Struts2结合应用,用图表直观展现后台数据分析结果
- struts2 <s:textfield />中的日期格式化输出
- struts2 <s:submit>国际化时提示警告关于ognl.OgnlException: target is null for setProperty(null的解决方案
- struts2 国际化 <s:if test="%{#session.WW_TRANS_I18N_LOCALE.toString()=='zh_CN'}">
- struts2 访问国际化资源 <s:text>作为属性
- SpringMVC 数据的格式化、JSR 303数据校验和国际化
- Struts2学习总结(3)--值栈,Ognl表达式,Struts标签库,国际化,数据校验,拦截器
- SpringMVC 数据的格式化、JSR 303数据校验和国际化
- Struts2学习总结(3)--值栈,Ognl表达式,Struts标签库,国际化,数据校验,拦截器
- jquery-ajax请求action读取oracle数据库clob字段xml数据格式化显示(struts2)
- Struts2 Chater 4&5 Struts2中的验证输入和数据类型的转换
- Struts2国际化和数据验证
- 框架 day28 Struts2-封装数据,类型转换,数据校验,国际化,拦截器
- springmvc_3_数据转换 & 数据格式化 & 数据校验
- 【转载】一些数据格式化-Eval( " ")和DataBinder.Eval(Container.DataItem, " ")的区别及用法&DataFormatString使用笔记
- Struts2 入门4 数据校验_类型转换_国际化
- c#List泛型数据扩展,把List<>型数据格式化成List<SelectListItem>,用来作dropdownlist的数据