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.
我是 servlet 世界的新手。我想在 servlet 的 WEB-INF(或 WEB-INF/some_folder)文件夹中创建一个文件。这应该在服务器启动时完成。请让我知道怎么做。
提前致谢。
要点:您可以从 servlet 访问文件,但不能从 Web 容器访问它们
String filename = "/WEB-INF/somefile.xml" ; ServletContext context = this.getServlet().getServletContext(); String pathname =context.getRealPath(filename);