我的resource.properties文件编译之后在conf下, 非classes ,如果我想读取该文件的属性值, 该怎么读取 ,路径如何写?
应该获取项目的发布路径,然后再拼接上 /WEB-INF/conf 。可以添加一个容器启动执行的 Servlet 获取项目的发布路径:
String dir = request.getServletContext().getRealPath("/");
System.getProperty("user.dir")为项目根目录
System.getProperty("user.dir")/WEB-INF/conf为路径,如果你的WEB-INF上面还有一层文件路径,加上即可