码迷,mamicode.com
首页 > 其他好文 > 详细

struts--国际化

时间:2014-07-26 03:35:57      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:style   文件   io   re   c   cti   line   res   

1.编写国际化的资源文件:

    1>.包范围的资源文件(只允许包下面的action访问)

         格式:package_language_country.properties

            package_zh_CN.properties    package_en_US.properties

    2>.类范围的资源文件:(放到action所在的类路径下)

        格式:ActionName_language_country.properties

    3>全局范围的资源文件(可以被所有的action和JSP访问,一般放到SRC文件下):

       格式:BaseName_language_country.properties

        注意:全局范围资源文件不是自动加载的,需要配置常量struts.custom.i18n.resources,其值就是BaseName

        可在struts.xml中配置:

            <constant name="struts.custom.i18n.resources" value="globalMessage"/>

            或者struts.properties中配置:struts.custom.i18n.resources=BaseName

2.访问国际化的资源文件:

    1>通过ActionSupport类的getText()方法,其参数name对应着key值,通过key值获取value值

    2>标签<s:text name="">标签中name属性即对应key值根据key即可获取value值

    3>表单元素中指定一个key值即对应资源文件中的key值,根据key即可获取value值

struts--国际化,布布扣,bubuko.com

struts--国际化

标签:style   文件   io   re   c   cti   line   res   

原文地址:http://my.oschina.net/u/1765238/blog/294898

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!