posts - 0, comments - 0, trackbacks - 0, articles - 8
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Struts2国际化解决方案(一)

Posted on 2008-04-16 23:08 Glen-Seto 阅读(191) 评论(0)  编辑  收藏 所属分类: Struts2学习
Struts提供了2种方式来输出国际化信息:
(1) <s:text name="messageKey"/>                                                         使用标签来输出
(2)<s:property value="%{getText("messageKey")}"/>                            使用表达式输出

一、资源文件的命名方式为
        basename_语言代码_国家代码.properties
        basename_语言代码.properties
        basename.properties

二、配置的方式为在struts.properties文件中加入
            struts.custom.i18n.resources=messageResource   其中messageResource为上面的basename。
        或者在struts.xml种加入
            <constant name="struts.custom.i18n.resources"  value="messageResource" />

三、把文件放入WEB-INF/classes下。