[英]Java web application context
I have a Java web application. 我有一个Java Web应用程序。 Inside the WAR I have a folder containing configuration files for the application.
在WAR内部,我有一个文件夹,其中包含该应用程序的配置文件。 I need to know the path of the folder in order to load the files at runtime.
我需要知道文件夹的路径,以便在运行时加载文件。
I also need the solution to work in Tomcat and in WebSphere. 我还需要该解决方案才能在Tomcat和WebSphere中工作。
Thanks. 谢谢。
I would suggest placing the files under WEB-INF/classes
and simplying loading them from the classpath, not from the filesystem. 我建议将文件放在
WEB-INF/classes
,并简单地从类路径而不是从文件系统中加载它们。 This way, the path is always the same. 这样,路径总是相同的。
You can use something like: 您可以使用类似:
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("path");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.