struts中如何确定当前程序的根目录?

解决方案 »

  1.   

    你path直接设为资源文件具体的路径不就找到了?
    String strPath = getServlet().getServletContext().getRealPath("/"); 
    获得的就是你工程所在的目录后面你在加上具体的资源文件在你的工程中的位置,应该ok了
      

  2.   

    ServletContext context = evt.getServletContext();
    String path = context.getRealPath("/");