【问题标题】:Wildfly image and http access to show imageWildfly 图像和 http 访问以显示图像
【发布时间】:2016-01-11 15:35:15
【问题描述】:

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

应用程序使用了很多图像,我不想将它们存储在数据库中,因此将它们写入硬盘。

如何配置 Wildfly/Undertow 以便在某个 URL 上提供这些文件,例如 http://localhost:18080/picture/produit.jpg

【问题讨论】:

标签: jakarta-ee wildfly


【解决方案1】:

您可以在 undertow 配置中添加文件处理程序:

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
        <buffer-cache name="default"/>
        <server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <location name="/picture" handler="pictures"/>
                <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="pictures" path="${jboss.home.dir}/my_local_dir"/>
        </handlers>
        <filters>
            <response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
            <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
        </filters>
    </subsystem>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-19
    相关资源
    最近更新 更多