【发布时间】:2014-01-28 18:32:55
【问题描述】:
我正在尝试从backupData.properties 读取一些道具。它位于WEB-INF/classes/。我就是这样做的:
public class Configures {
private static final String INPUT_FILE = "WEB-INF//classes//backupData.properties";
public static String getMail() {
Properties prop = new Properties();
try {
//load a properties file
prop.load(new FileInputStream(INPUT_FILE));
//get the property value
return prop.getProperty("mail");
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
}
INPUT_FILE 应该包含什么?我试图把它放在src 中,比如src//backupData.properties,但它会抛出FileNotFoundException。我用谷歌搜索该文件应该位于CLASSPATH(据我所知在WEB-INF/classes)。怎么了?
PS。我正在使用 Spring。
【问题讨论】:
-
你检查绝对路径吗??
标签: java spring-mvc properties