works perfectly for fomatting my date to the french standard.
But It\'s hard-written in my jsp. So I ha
Create localized date format inside your properties files, e.g. with struts.date.format
key:
struts.date.format = dd.MM.yyyy
And use getText
method to get this date format in <s:date>
tag format
attribute:
<s:date name="date" format="%{getText('struts.datetime.format')}"/>
Absolutely. Internationalization (i18n
) is handled out-of-the-box in almost every framework out there, then it's better to spend time on understand how to make it works than to write some unneded, buggy custom solution.
With Struts2, you must ensure to have:
<constant name="struts.custom.i18n.resources" value="global" />
;request
_locale` parameter (if you have not changed the language in your browser) when calling your Actions, giving the I18nInterceptor the ability to hijack the request to the correct resource;<%@ page contentType=”text/html;charset=UTF-8″ %>
.Take a look at the guides available on the web too:
http://www.mkyong.com/struts2/struts-2-i18n-or-localization-example/
http://www.2bloggers.com/2011/12/localization-i18n-in-struts2.html
http://www.roseindia.net/struts/struts/struts2.2.1/tags/i18ntag.html
http://www.roseindia.net/struts/strutsinternationalization.shtml
http://www.roseindia.net/tutorials/I18N/internationalison-code.shtml