如何在 jBoss AS 7 中配置静态资源
我想将图像上传到服务器,将它们存储在文件系统(服务器外部)中,然后将它们显示在我的 JSF 页面上。
我想找到这样的东西:
<?xml version="1.0" encoding="UTF-8"?>
<Context allowLinking="true" cookies="true" crossContext="true" override="true">
<Resources allowLinking="true"
className="com.triplemind.site.engine.SourceResolverContext"
homeDir="/home/myapp/files" />
</Context>
我找到了一些解决方案,但我想知道是否有更好的方法来做到这一点。
我找到了jBoss文档:
任何帮助将不胜感激。提前致谢
I'd like to upload images to the server, store them in file system (outside server) and then display them on my JSF page.
I'd like to find something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Context allowLinking="true" cookies="true" crossContext="true" override="true">
<Resources allowLinking="true"
className="com.triplemind.site.engine.SourceResolverContext"
homeDir="/home/myapp/files" />
</Context>
I found some solutions, but I wonder if there is a better way to do this.
- Configure static resources in JBOSS AS 7 (not answered)
- Replacement for context.xml in AS7? Access files outside the
WAR? (not answered)
There are jBoss documentation I've found:
Any help will be appreciated. Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后,我决定使用 BalusC 实现的 FileServlet (link< /a>)。这个解决方案目前适合我。我只是将其
basePath
更改为我的服务器上的某个特定路径。Finally, I've decided to use FileServlet implemented by BalusC (link). This solution suits me for now. I've only changed its
basePath
to some certain path on my server.JBoss 论坛上记录的此方法适用于我们从展开的文件夹加载所有静态资源 - 该文件夹必须位于 JBOSS_HOME 但至少未打包在 EAR/WAR 中。
夹
我必须创建一个名为的模块文件 com/mycompany/main 并在其中添加所有图像。
跳过步骤 3 并使用步骤 4。 (Manifest.MF 条目 - 有效)
加载图像
现在使用
URL imgUrl = this.getClass().getClassLoader().getResource("myimage.jpg");
This method documented on the JBoss forums works for us in loading all the static resources from an exploded folder - which has to sit within JBOSS_HOME but at least not packaged in EAR/WAR.
https://community.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath
I had to create a module folder called com/mycompany/main and add all the images in there.
Skip step 3 and use step 4 instead. (Manifest.MF entry - which works)
The image is now loaded using
URL imgUrl = this.getClass().getClassLoader().getResource("myimage.jpg");