如何配置Wildfly提供静态内容(如图片)? [英] How to configure Wildfly to serve static content (like images)?

查看:253
本文介绍了如何配置Wildfly提供静态内容(如图片)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a JavaEE application running on Wildfly 8.0.0 Final.

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

The application uses a lot of images and I don't want to store them in the database, so they are written to the hard disk.

如何配置Wildfly/Undertow,以便在特定的URL(例如http://localhost:8080/myapplication/imagesFromDisk)上投放这些文件(/var/图像)?

How can I configure Wildfly/Undertow in order to serve these files (/var/images) on a certain URL, for example http://localhost:8080/myapplication/imagesFromDisk?

推荐答案

在standalone.xml中向undertow子系统添加另一个文件处理程序和另一个位置:

Add another file handler and another location to the undertow subsystem in 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>

这篇关于如何配置Wildfly提供静态内容(如图片)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆