IT程序员开发必备-各类资源下载清单,史上最全IT资源,个人收藏总结!
准备资源文件,资源文件的命名格式如下:
baseName_language_country.propertiesbaseName_language.properties
baseName.properties
其中baseName是资源文件的基本名,我们可以自定义,但language和country必须是java支持的语言和国家。如:
中国大陆: baseName_zh_CN.properties
美国: baseName_en_US.properties
国际化--全局(整个应用都能访问)
第一个存放中文:itcast_zh_CN.properties 内容为:welcome=欢迎来到传智播客
第二个存放英语(美国): itcast_en_US.properties 内容为: welcome=welcome to itcast
对于中文的属性文件,我们编写好后,应该使用jdk提供的native2ascii命令把文件转换为unicode编码的文件。命令的使用方式如下:
native2ascii 源文件.properties 目标文件.properties
(2)在struts.xml中配置常量
<!-- 全局资源文件基名subjob,在没有包/action范围的资源文件情况下, 则struts在sunjob_language_country.properties中寻找key值,以实现国际化 -->
<constant name="struts.custom.i18n.resources" value=&#