如何托管和引用 Ear 文件中的静态内容
我们有多个 j2ee 应用程序(例如 A.ear、B.ear、C.war)在单个 jboss 实例中运行,我们需要在这些应用程序之间共享一组静态文件。所以我应该能够以 http://myhost/folderA/fileA.htm 的形式访问这些文件或 http://myhost/folderB/file.js 来自我的耳朵或战争文件。
我应该如何告诉 jboss appserver (5.1.0) 查找这些文件,我应该如何在我的 server/default/deploy
目录或 docs
中部署此静态内容文件夹
We have several j2ee applications (e.g. A.ear, B.ear, C.war) running in a single jboss instance, we have a requirement to share a set of static files across these applications. So I should be in a position to access these files as http://myhost/folderA/fileA.htm or http://myhost/folderB/file.js from within my ear or war files.
How should I tell the jboss appserver (5.1.0) to look for these files, how should I deploy this static content in my server/default/deploy
directory or the docs
folder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将 jboss 与 Jetty 服务器一起使用,则可以重复使用 org.mortbay.jetty.servlet.DefaultServlet。我确信 tomcat 有类似的东西,或者您可以只添加 jetty 一个(因为它是一个 servlet,它将在任何 servlet 容器上运行)。
尽管自己编写它相对容易,但这并不是因为高质量的实现需要很多东西。
看一下
DefaultServlet
的文档了解如何配置它,它有很多功能。If you're using jboss with the Jetty server, you can re-use the
org.mortbay.jetty.servlet.DefaultServlet
. I am sure tomcat has something similar or you can just add the jetty one (because it's a servlet, it will run on any servlet container).Even though it's relatively easy to write it yourself, it's not because there are a bunch of things a quality implementation needs.
Take a look at the documentation of the
DefaultServlet
on how to configure it, it has many features.您应该能够将静态文件放在一个位置,并让每个上下文(A、B、C...)都有一个服务这些静态文件的 servlet。
如果您可以将其配置为在正确的文件夹中查找,则您可以重用现有的 servlet,例如
DefaultServlet
。或者,您可以编写自己的 servlet 来提供静态内容:我曾经在这里写过一个< /a>.You should be able to place the static files in one location and have each of your contexts (A, B, C,...) have a servlet that serves these static files.
If you can configure it to look in the right folder, you may be able to reuse an existing servlet like
DefaultServlet
. Or you may code your own servlet to serve static content: I once wrote one here.