我试图从backupData.properties
中读取一些道具。它位于WEB-INF/classes/
。我是这样做的:带属性文件的FileNotFoundException
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
。我GOOGLE了那个文件应该在CLASSPATH
(根据我的理解,在WEB-INF/classes
)。哪里不对?
PS。我正在使用Spring。
你用绝对路径检查吗? – Kick