struts中的路径问题

1 .System.out.println(request.getRealPath("/")); //或取绝对路径,已过期

    C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/project2/
2.System.out.println(this.servlet.getServletContext().getRealPath("/")); //获得绝对路径

    C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/project2/
3.System.out.println(request.getServletPath());
     /Pmafhn10.do

4.System.out.println(request.getContextPath());//获取相对路径
     /project2

 

 





 

你可能感兴趣的:(c,struts)