简体   繁体   English

如何获取Web应用程序war文件的路径?

[英]How to get the path of web application's war file?

I need to get the full file path of war file using just the war file name as input. 我需要仅使用war文件名作为输入来获取war文件的完整文件路径。 I mean, the return value should be like C:/PFiles/project/tomcat/sender/sender.war 我的意思是,返回值应类似于C:/PFiles/project/tomcat/sender/sender.war

I have tried to get the path using the following, but it doesn't give me the correct path. 我尝试使用以下方法获取路径,但它没有给我正确的路径。

File file = new File("sender.war");
String path = file.getAbsolutePath();

How to find the correct path? 如何找到正确的路径?

Try using the system property of tomcat. 尝试使用tomcat的系统属性。 String tomcatHome = System.getProperty( "catalina.base" );

This will give you the home directory from there you can add tomcatHome+"webapps/yourwar" . 这将为您提供主目录,您可以在其中添加tomcatHome+"webapps/yourwar"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为Web应用程序设置tomcat上下文路径? .war文件名正在url中的应用程序名称前面 - How to set up tomcat context path for web application? .war file name is coming infront of the application name in the url 如何外部化Web应用程序的属性文件(WAR)? - How to externalize properties file for web application(war)? Java Web Application:如何获取所选文件的原始路径? - Java Web Application:how to get the original path of selected file? 如何在Netbeans中构建我的Web应用程序后运行.war文件 - How to run a .war File after building my Web Application in Netbeans 如何在远程服务器上上传和部署 java web 应用程序(war 文件)? - How to upload and deploy java web application (war file) on remote server? 如何在maven war项目中获取pom文件的路径 - How to get the path of the pom file in a maven war project 如何在war文件中提到路径? - how to mention path in war file? 如何在web.xml Web应用程序的设置文件中配置url路径? - how to configure the url path in web.xml web application's setting file? classloader和Web应用程序以及war文件的lib目录 - classloader and web application and the lib directory of war file 将旧版Web应用程序转换为WAR文件 - convert legacy web application into WAR file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM