资源文件properties的存放路径

参考这篇博客:http://lavasoft.blog.51cto.com/62575/184605

目前看来,大多数的做法是这样的:

比如a.properties需要被com.xxx.yyy这个包中的类访问,比如说需要被com.xxx.yyy.SomeClass访问,那么就放到D:/YourSite/WebContent/WEB-INF/classes/com/xxx/yyy这个路径下

访问方法:

ResourceBundle.getBundle("com.xxx.yyy.a").getString("key")

如果a.properties中有这么一条

key = hello world

那么你得到的String就是"hello world"

注意ResourceBundle.getBundle()的documentation是这么写的,我尝试了网络上的所谓的把资源文件的路径添加到CLASSPATH中,没有效果。后来参考这篇博客才解决的问题:http://blog.csdn.net/yysjch/article/details/7606741

Parameters:

  baseName the base name of the resource bundle, a fully qualified class name

原文地址:https://www.cnblogs.com/qrlozte/p/3543006.html