`

displaytag中使用struts的国际化资源

    博客分类:
  • Java
阅读更多
    使用displaytag打印表格的时候,表头有时需要使用国际化资源,这些资源往往是properties文件。在开发中各种框架都有自己的国际化资源规则,JSTL,struts,spring,默认displaytag会读取jstl制定的资源文件。
    TODO: JSTL, Struts, spring i18n
    项目中原有框架(类似appfuse)把struts和jstl的国际化资源都指向ApplicationContext,这个文件是struts的默认资源文件。项目中,struts在struts-plugin.xml中制定
<constant name="struts.custom.i18n.resources" value="testmessages,testmessages2" />

http://struts.apache.org/2.x/docs/constant-configuration.html

    jstl则是通过web.xml中制定
<context-param> 
  <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> 
  <param-val>message</param-val> 
</context-param> 

    jstl,似乎不能制定多个资源文件,这在项目中有些限制,所以我采用struts国际化方式。

displaytag中使用struts资源只需在displaytag.properties文件中添加。
locale.provider=org.displaytag.localization.I18nStrutsAdapter

column中指定titleKey
<display:column property="prop" titleKey="Title.Column.one" />


I18nJstlAdapter,I18nSpringAdapter分别对应jstl和spring。
对于资源文件:You don't need to copy all the properties in any internationalized file (some of them are also configuration properties which don't need to be translated at all). Configure displaytag properly in the main displaytag.properties file and then replicate only the strings you want to translate.

reference:http://displaytag.sourceforge.net/1.2/i18n.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics