简体   繁体   中英

Java web application context

I have a Java 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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM