java中在tomcat获取绝对路径的问题。。。。。。。。急啊。。。。

用java代码如何获取到tomcat的安装路径呢?
可以同时在windows和linux下执行的代码。

System.out.println(new File(System.getProperty("user.dir")));System.out.println(new File(System.getProperty("catalina.home")));
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-04-12
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
第2个回答  2012-04-05
楼上是在网上粘的
相似回答