在jsp页面中:<%String path = application.getRealPath("").replace("\\","\\\\");%>在java代码中:String path = request.getServletContext().getRealPath("").replace("\\","\\\\");