国际化

来源:互联网 发布:绿色建筑评价软件 编辑:程序博客网 时间:2024/04/30 10:21

 1、<s:text name="hello"></s:text>  hello利用国际化语言


2、@SuppressWarnings("unchecked")
 注释类型
 当你的编码可能存在警告时,比如安全警告,可以用它来消除

3、actionerror方式利用资源文件时:
 this.addActionError(this.getText("key"))    
 要传递参数时:
 List list = new ArrayList();
 list.add(参数)
 this.addActionError(this.getText("key",list))
 或:
 String[] list =new String[]{"参数1",。。。。}
 this.addActionError(this.getText("key",list))
 上面的key是指资源文件中的key

 同样fielderror也有上面同样的方法

4、在验证框架中 利用<message key="key"></message>进行国际化

5  国际化资源文件有:全局的,包级,类级的。
 如包级的:package_en_US.properties   
    package_zh_CN.properties
 全局的:globalMessages_en_US.properties 
  globalMessages_zh_CN.properties
 类级的:类名_en_US.properties  
  类名_zh_CN.properties 

先找类级的--->包级的---->全局 

6、
<s:i18n name="指定资源文件">
 <s:text name="资源文件中的key">
  <s:param>value</s:param>//value是传递的参数
 </s:text>
</s:i18n>
上面的资源文件要放到根目录下