开发者

Java web application context

开发者 https://www.devze.com 2023-02-21 02:38 出处:网络
I have a J开发者_Go百科ava web application. Inside the WAR I have a folder containing configuration files for the application. I need to know the path of the folder in order to load the files at runti

I have a J开发者_Go百科ava web application. Inside the WAR I have a folder containing configuration files for the application. 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.

Thanks.


I would suggest placing the files under WEB-INF/classes and simplying loading them from the classpath, not from the filesystem. This way, the path is always the same.

You can use something like:

InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("path");
0

精彩评论

暂无评论...
验证码 换一张
取 消