如何在WildFly的战争之外提供静态资源

use*_*892 9 wildfly undertow wildfly-8

我可能错了,但根据我的理解,WildFly必须具备以下功能:

必须可以将我的JSF视图(即xhtml文件)链接到WildFly服务器上已有的资源(pdf,图像,其他xhtml文件).

我可以在php和apache服务器上做同样的事情.

我需要在哪里放置这些资源,如何从我的视图中访问它们?E. g.将视图中的链接放到pdf文件中,该文件在新选项卡中打开pdf文件.

非常感谢您的提示和提示!!

编辑

standalone.xml

<server name="default-server">
    <http-listener name="default" socket-binding="http" max-post-size="974247881"/>
    <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
        <location name="/content" handler="ContentDir"/>
        <filter-ref name="server-header"/>
        <filter-ref name="x-powered-by-header"/>
    </host>
</server>
<servlet-container name="default">
    <jsp-config/>
    <websockets/>
</servlet-container>
<handlers>
    <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    <file name="ContentDir" path="${jboss.home.dir}/standalone/data/unzipped" directory-listing="true"/> 
</handlers>
Run Code Online (Sandbox Code Playgroud)

链接在JSF视图中

<h:outputLink value="http://localhost:8181/content">KLICK</h:outputLink>
Run Code Online (Sandbox Code Playgroud)

当我点击这个时,我得到目录列表,如你所说.

但是我怎样才能使它显示index.xhtmlcontent指向的目录中?这就是我想要的.

content指向${jboss.home.dir}/standalone/data/unzipped和解压缩有一个index.xhtml以及另一个包含更多.xhtml文件的文件夹.

在文件夹中的文件index.xhtml有相对链接.xhmtl:

<ul>
    <li><a href="t/rt.html">hg</a></li>
    <li><a href="t/tert.html">jghj</a></li>
    <li><a href="t/gf.html">jghj</a></li>
    <li><a href="t/hg.html">jghj</a></li>
    <li><a href="t/hgfh.html">jghj</a></li>
    <li><a href="t/hfgh.html">jhgj</a></li>
    <li><a href="t/hfgh.html">jhgj</a></li>
    <li><a href="t/hg.html">jghj</a></li>
    <li><a href="t/hghh.html">jghj</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我想index.xhtmlunzipped那里显示文件导航到其他.xhtml文件.

这样的东西一定是可能的,一定不是吗?

或者你怎么写一个应用程序,用户可以将html文件上传到Java ee服务器,然后看到显示的那些文件?

Sev*_*rse 12

您可能不希望在应用程序中部署所有静态内容.这些可以是图像,PDF文档或其他类型的文件.您应该配置Undertow以解决此问题.下面的示例演示如何通过配置Undertow子系统来完成此操作.

<server name="default-server">
    <http-listener name="default" socket-binding="http"/>
    <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
        <location name="/img" handler="images"/>
    </host>
</server>
<handlers>
    <file name="welcome-content" path="${jboss.home.dir}/welcome-content" directory-listing="false"/>
    <file name="images" path="/var/images" directory-listing="true"/>
</handlers>
Run Code Online (Sandbox Code Playgroud)

使用此附加配置,任何资源请求www.sampledomain.com/contextroot/img都将重定向到硬盘上的文件系统.如果将"directory-listing"属性标记为false,则请求将被重定向为正确显示的文件.