创建配置文件:格式  文件名_语言_国家.properties (文件名后面都是固定的),如:

app_en_US.properties

app_zh_CN.properties

JAVA调用文件:

View Code
public static void main(String[] args) {
ResourceBundle res = ResourceBundle.getBundle("app", Locale.CHINA);
System.out.println(res.getString("welcome.msg" ));
}


会自动调用   app_zh_CN.properties  文件中的welcome.msg对应的value值。

 

注:properties 不让存中文。解决办法:

1.用JDK中的转换程序 native2ascii.exe 转换成UTF8格式的ascii码。

2.struts1可以装一个插件来解决,struts2也是这么做的。(propertieseditor)

 

相关文章:

  • 2022-02-16
  • 2021-12-08
  • 2021-05-22
  • 2021-11-14
  • 2021-11-28
  • 2021-09-04
  • 2021-10-29
猜你喜欢
  • 2021-12-30
  • 2022-12-23
  • 2021-08-13
  • 2021-10-07
  • 2021-12-22
  • 2021-12-01
  • 2022-12-23
相关资源
相似解决方案