0 0

java web 项目 .properties 文件路径 怎么获取0


如题:

  我想在 action 里,将数据 写入 配置文件,但是 我获取不到 配置文件的路径

求解释 .

求解决 .

2014年8月15日 16:31

3个答案 按时间排序 按投票排序

0 0

采纳的答案

通过System.getProperty("user.dir");或者request.getServletConctext().getRealPath();获取绝对路径,然后再拼路径。
或者

2014年8月15日 17:02
0 0

InputStream in =    Thread.currentThread().getContextClassLoader().getResourceAsStream("文件名");
Properties properties = new Properties();
properties.load(in);
//获取.properties文件key对应的值
properties.getProperty(key);

2014年8月19日 12:00
0 0

resourcebundle

2014年8月15日 17:52

相关推荐

Global site tag (gtag.js) - Google Analytics