如何从 Java Web 应用程序访问 WEB-INF 下的文件

发布于 2024-08-23 09:41:32 字数 161 浏览 4 评论 0原文

您知道如何从我的应用程序访问 WEB-INF/index 文件夹中的文件吗?我在我的应用程序中使用 OpenCMS,我想打开位于 WEB-INF/index 文件夹的 Lucene 搜索索引(借助 Lucene IndexReader 类)。 Lucene jar 存储在 WEB-INF/lib 文件夹中。

Do you have any idea how to access files in WEB-INF/index folder from my application? I'm using OpenCMS for my application and I want to open a Lucene search index (with the help of Lucene IndexReader class) located at WEB-INF/index folder. Lucene jar is stored in WEB-INF/lib folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

平生欢 2024-08-30 09:41:32

如果要查找WEB-INF文件夹下RFS(真实文件系统)上的文件,可以通过: 获取路径,

String filepath = pageContext.getServletContext().getRealPath("/") + "WEB-INF" + java.io.File.separator + "index";

然后使用常见的java文件方法读取。

If you want to lookup a file on the RFS (real file system) under the WEB-INF folder, you can get the path via:

String filepath = pageContext.getServletContext().getRealPath("/") + "WEB-INF" + java.io.File.separator + "index";

and then use the common java file methods to read it.

昔日梦未散 2024-08-30 09:41:32

您打算如何处理这些索引文件?

OpenCms 使用 Lucene 作为其搜索引擎。如果索引文件位于“正确”文件夹中,则可以在 OpenCms 中将 Lucene 用于其他目的,而不会遇到任何麻烦。

What do you intend to do with those index files?

OpenCms uses Lucene for its search engine. It is possible to use Lucene from within OpenCms for other purposes without any hassle if the index files are in the "correct" folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文