Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 HttpServlet 中使用以下代码。
String pathToWeb = getServletContext().getRealPath(File.separator);
我有应用程序,上面的代码工作正常并返回应用程序目录的真实路径。而我发送另一个分支进行 QA 并且无法使用上面的代码检测到实际路径。
在 Windows 服务器上使用 java8,tomcat8 总是返回 null。请协助。
我已经经历过这样的问题,但无法找到解决方案。
用于/上下文根的路径:
/
getServletContext().getRealPath("/")
而不是特定于操作系统的文件分隔符。