JSP:String sLocalRealPath = application.getRealPath("/").replace(‘‘, ‘/‘);if (sLocalRealPath != null && !sLocalRealPath.endsWith("/")){ sLocalRealPath += "/"; //避免 WebLogic 和 WebSphere 不一致}//前面会多返回一个"/", 例如 /D:/test/WEB-INF/, 奇怪, 所以用 substring()sClassRealPath = this.getClass().getResource("/").getPath().substring(1).replaceAll("\\", "/");System.out.println(sClassRealPath);