本帖最后由 linjky 于 2009-07-02 17:02:32 编辑

解决方案 »

  1.   

    application.getRealPath("/"); 这个就是你的项目的根目录。tomcat默认的当前目录是 tomcat/bin
      

  2.   

    可不可以用, Servlet.getSerletContextPath() 可能不太对, 
      

  3.   

    application.getRealPath("/"); 我试了,是获得我项目的绝对地址
    Servlet.getSerletContextPath();是获得的什么呀,还有Servlet怎么在struts2里怎么获取。
      

  4.   

    request.getContextPath()struts2 Action中获取request, response对象的方法  ActionContext ctx = ActionContext.getContext();        
           
      HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);        
           
      HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);  http://lxy19791111.javaeye.com/blog/135771
      

  5.   

    servlet里经常会用到一些GET方法,容易弄混,把它们记在这儿了。servletContext.getContextPath()=
    servletContext.getRealPath("/")=F:\ess-branch\web\
    servletContext.getRealPath("")=F:\ess-branch\web
    servletContext.getContextPath()=
    servletContext.getServerInfo()=Apache Tomcat/6.0.18
    http://hi.baidu.com/atomicface/blog/item/de62ac10c099c8cea6ef3f5b.html
      

  6.   

    用servletContext.getRealPath(path)或request.getServletContext().getRealPath(path);
    不要用request.getRealPath(path),这个方法在api中是不推荐的,部分服务器不支持此方法(如某些版本的weblogic)