Why does getRealPath() return null when deployed with a .war file? [duplicate]
问题 This question already has answers here : What does servletcontext.getRealPath(“/”) mean and when should I use it (4 answers) Closed last year . getRealPath() is returning the actual path in the local system, but returns null when deployed with a .war file. <%@ page import="java.io.*" %> <%@ page contentType="text/html;charset=ISO-8859-1" %> <% int iLf = 10; char cLf = (char)iLf; String a= application.getResource("/"); //String myfile = application.getRealPath("/")+ "generate.xml"; //String