How can I serve static resources from outside a war on WildFly

感情迁移 提交于 2019-11-29 10:06:07

You may not want to deploy all your static content with your application. These may be images, PDF documents, or other types of files. You should configure Undertow in order to solve this problem. Below example shows you how to do this by configuring Undertow subsytem.

<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>

With this additional configuration, any request for resources to www.sampledomain.com/contextroot/img will be redirected to the filesystem on your hard disk. If you mark "directory-listing" attribute as false, then requests will be redirected as a properly displayed file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!