做练习的时候,写了个properties文件,放在src/servlet/目录下,访问文件问题花了点时间折腾,最终得到解决,记下。
环境:eclipse jee oxygen,tomcat 9.0。
protected String getValue(String key) throws IOException {
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream(this.getServletContext().getRealPath("/") + "WEB-INF/classes/servlet/servlet.properties"));
props.load(in);
return props.getProperty(key);
}
本文介绍了一种在Eclipse JEE Oxygen环境下使用Tomcat 9.0读取位于servlet目录下的properties文件的方法,并提供了一个具体的Java实现示例。

803

被折叠的 条评论
为什么被折叠?



