ServletContext servletContext = (ServletContext)ActionContext.getContext().get(ServletActionContext.SERVLET_CONTEXT); String rootPath = servletContext.getRealPath("/"); ------------------------------------------------- //方法二: String rootPath = ServletActionContext.getServletContext().getRealPath("/");
自:http://georgeinfo.blog.163.com/blog/static/1636833412011235525318/