Struts2 : internationalize s:date?

前端 未结 2 1617
眼角桃花
眼角桃花 2021-01-24 20:46

works perfectly for fomatting my date to the french standard. But It\'s hard-written in my jsp. So I ha

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-24 21:34

    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:

    • I18nInterceptor in your Interceptor Stack;
    • I18nInterceptor defined in struts.xml: ;
    • the localized, correctly named global.properties file for each locale you want to handle;
    • the 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;
    • an appropriate character encoding on your pages: <%@ 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

提交回复
热议问题