简体   繁体   中英

Resolving path in tomcat 9

I have this piece of code:

Paths.get("conf/app.properties").toAbsolutePath()

When I run it in Tomcat 7, it properly resolves to a relative directory, using $CATALINA_HOME . But when I run it in Tomcat 9, it "resolves" to /conf/app.properties which obviously doesn't exist. How do I get Tomcat 9 to properly resolve the path?

I checked this answer - seems to be doing something close to what you need: Reading properties from tomcat

I came up quickly from that to something like:

<%= new File(System.getProperty("catalina.base"), "conf").getAbsolutePath() %>

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