常量i18n的配置问题

来源:互联网 发布:打电话变声软件 编辑:程序博客网 时间:2024/06/06 12:59

很多人都知道struts2的i18n表示的是程序的国际化,当然我们还可以用作对properties文件属性的读取,使用了一段时间,发现自己的程序一直都是对一个资源文件的读取,如果我想读取多个资源文件,又想分包读取怎么办

其实struts提供了这样的方式,采用的是“包.资源名称”和中间用逗号分割的方式,如:<constant name="struts.custom.i18n.resources" value="resource.message,config.property"></constant>。要注意的是不能配置多个的,会覆盖,如:<constant name="struts.custom.i18n.resources" value="resource.message"></constant><constant name="struts.custom.i18n.resources" value="config.property"></constant>最终读取的是config.property,resource.message被覆盖了。

此外你想在你的程序中获取里面的值,直接实现TextProvider, LocaleProvider接口即可。

原创粉丝点击