如何配置Wildfly以提供静态内容(如图像)?

Chr*_*ötz 36 static-content wildfly undertow

我有一个在Wildfly 8.0.0 Final上运行的JavaEE应用程序.

应用程序使用大量图像,我不想将它们存储在数据库中,因此它们被写入硬盘.

例如,如何配置Wildfly/Undertow以便在某个URL上提供这些文件(/ var/images)http://localhost:8080/myapplication/imagesFromDisk

Har*_*ann 59

将另一个文件处理程序和另一个位置添加到standalone.xml中的上流子系统:

<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="true"/>
    <file name="images" path="/var/images" directory-listing="true"/>
</handlers>
Run Code Online (Sandbox Code Playgroud)