不废话,直接来方法:
方式一:
适用场景: jsf ResourceBoundle FacesContext facesContext = FacesContext.getCurrentInstance();
ResourceBundle resourceBundle = facesContext.getApplication().getResourceBundle(facesContext, "configBundle");
String imgaePath = resourceBundle.getString("paths.pictureUrl");
 
此种方法使用的前提:
    jsf 页面  与  bean 的交互采用下面这种方式
方式二:
 public Map<String, String> getProperties() {
        Properties props = new Properties();
        Map<String, String> map = new HashMap<String, String>();
        try {
            InputStream in = ApiRequestFilter.class.getClassLoader().getResourceAsStream("config.properties");
            props.load(in);
            Enumeration en = props.propertyNames();
            while (en.hasMoreElements()) {
                String key = (String) en.nextElement();
                String property = props.getProperty(key);
                map.put(key, property);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
}此种方法的思路:
         当前类的反射读取编译后的文件,形成输出流;
         创建Properties对象,并加载输出流;
         根据属性获取所有明细;
         遍历所有明细;
         先获取key,Properties根据key 获取value最后存放到集合里面;
         返回结果就可以。最后总结一点: 两种方法的适用场景不一样,大家切记,细节点: config.properties, 路径经常错,一定要多尝试,路径问题,是关键.