A. java,获取已发布tomcat项目的原始地址路径

String dir = request.getServletContext().getRealPath("/");
request怎么来的就不多说了吧!!

B. tomcat启动时就java类就获取tomcat服务器路径

String path = null;
File file = new File(".");
try {
path = file.getCanonicalPath();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

这个path就是TOMCAT\BIN目录

C. 如何在java类里获取tomcat容器的绝对路径=

可以通过“ 类名.class.getResource("").getPath()”方法实现。

D. 如何获取tomcat下的webapps的绝对路径呢

//获取当前项目的绝对路径

public String getPorjectPath(){

String nowpath; //当前tomcat的bin目录的路径 如 D:\java\software\apache-tomcat-6.0.14\bin

String tempdir;

nowpath=System.getProperty("user.dir");

tempdir=nowpath.replace("bin", "webapps"); //把bin 文件夹变到 webapps文件里面

tempdir+="\\"+projectName; //拼成D:\java\software\apache-tomcat-6.0.14\webapps\sz_pro

return tempdir;

}

E. 求助,java如何获取项目在tomcat的根路径

如果已经有系统环境变量的话,就用System.getEnv("TOMCAT_ROOT"),当然你要自定义TOMCAT_ROOT到系统变量里面。

F. java 获取tomcat 目录

需要放在webinf下的classes中
它自动加载时会把你的txt文件自动加载到webinf下的classes中去的。你想要取到路径的话
通过当前的类的class再得到getresoues路径名就可以了
xmlutils.class.getresource(filepath).getpath();我是这样得到了。

G. 如何通过Java代码获取tomcat服务器的绝对路径

//也许有你想要的,前提是在项目布署运行起来后,在servlet中或controller中运行以下代码即可。
System.out.println(this.getClass().getResource("/"));//结果:file:/E:/work/service/tomcat7.0.65/webapps/mvc_adminlte/WEB-INF/classes/
System.out.println(System.getProperty("catalina.home"));//结果:E:workservice omcat7.0.65
System.getProperty("user.dir");//结果:E:workservice omcat7.0.65in
System.out.println(request.getSession().getServletContext().getRealPath("/"));//结果:E:workservice omcat7.0.65webapps你的项目名称
希望能帮到你!

H. 在java程序中获得Tomcat下的webapps绝对路径的程序怎么写

jsp中:request.getContextPath()
servlet、action中:
HttpSession session = request.getSession();
ServletContext application = session.getServletContext();
String serverRealPath = application.getRealPath("/") ;