Struts2:将s:date国际化? [英] Struts2 : internationalize s:date?
问题描述
<s:date name="mydate" format="dd/MM/yyyy HH:mm" />
非常适合使我的约会符合法国标准.
但这在我的jsp中是很难写的.因此,我必须构建if子句以根据语言环境进行切换.
<s:date name="mydate" format="dd/MM/yyyy HH:mm" />
works perfectly for fomatting my date to the french standard.
But It's hard-written in my jsp. So I have to build if clause to switch according to the locale.
是否可以将这种格式添加到常规属性文件中?
我尝试过:
format.date = {0,date,dd/MM/yyyy}
format.time = {0,time,HH:mm}
输入我的全局.properties,但是当我只尝试<s:date name="mydate">
或<s:property value="mydate"/>
时却没有考虑.
put in my global .properties but it's not taken into account when, I try just a <s:date name="mydate">
or a <s:property value="mydate"/>
.
推荐答案
在属性文件中创建本地化的日期格式,例如用struts.date.format
键:
Create localized date format inside your properties files, e.g. with struts.date.format
key:
struts.date.format = dd.MM.yyyy
并使用getText
方法在<s:date>
标记format
属性中获取此日期格式:
And use getText
method to get this date format in <s:date>
tag format
attribute:
<s:date name="date" format="%{getText('struts.datetime.format')}"/>
这篇关于Struts2:将s:date国际化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!