ServletContext.getRealPath();java.lang.String getRealPath(java.lang.String path) 
          Returns a String containing the real path that corresponds to a virtual path. 

解决方案 »

  1.   

    <%=getServletContext().getRealPath("/test.jsp")%>
      

  2.   

    Returns a String containing the real path that corresponds to a virtual path. A virtual path contains a servlet name followed by the name of a file the servlet should act upon, in the form /dir/dir/servlet/file.ext. In this form, file.ext is a filename used instead of the path to the file. The servlet locates the file and translates the file name to the path that locates the file. 
    The real path the servlet returns is in a form appropriate to the computer and operating system on which the servlet engine is running, including the proper path separators. This method returns null if the servlet engine cannot translate the virtual path to a real path for any reason.
      

  3.   

    好了解决问题了.
           ServletConfig config = this.getServletConfig(); 
        ServletContext context = getServletContext();
           String path = context.getRealPath("");
    放一天让别人也看看,明天加分.