资源文件命名格式
name_language_country.properties
name_language.properties
name.properties
比如:
name_zh_CN.properties
name_en_US.properties
如果没用myeclipse 自动转换工具,可用jdk的 native2ascii 转换成utf码,即:
native2ascii 源文件.properties 目标文件.properties
资源文件访问取值:
<constant name="struts.custom.i18n.resources" value="name" />
jsp取值:
<s:text name="key"></s:text>
java取值:
getText()
带占位符的资源文件信息
message={0} ,welcom,i am {1}
jsp get value :
<s:text name="message">
<s:param>zs</s:param>
<s:param>li</s:param>
</s:text>
java get value :
getText("message",new String[]{"zs","lisi"});
包范围资源文件
可定义包范围资源文件,package_language_country.properties,属于该包的所有类都可访问资源文件中的定义,系统默认会先从相应的包资源文件找定义,如果没找到,再从全局资源文件中找。