用静态内容wildfly 10替换图像

时间:2017-01-27 15:26:55

标签: wildfly undertow static-content

在我们的应用程序中,JBoss 7.2上的静态内容部署了重写规则:

<rewrite name="rule-1" pattern="^(\/my_app\/(?!(exclude)\/)((.*)\.(css|gif|ico|jpg|PNG|png)))$" substitution="/another.war/my_app/$3" flags="L"/>

它工作正常

现在,在wildfly 10上我想部署静态内容,但我不能。下位子系统是:

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
                <buffer-cache name="default"/>
                <server name="default-server">
                    <http-listener name="default" socket-binding="http"/>
                    <host name="default-host" alias="localhost">
                        <location name="/" handler="welcome-content"/>
                        <location name="/my_app" handler="static"/>
                        <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="static" path="${jboss.home.dir}/welcome-content/my_app" directory-listing="true"/>
                </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>

预期的结果是,想要在浏览器中显示的图像将替换为路径上的图像,而不是图像中找不到的图像。

由于

1 个答案:

答案 0 :(得分:0)

您必须在虚拟主机中使用Undertow谓词http://undertow.io/undertow-docs/undertow-docs-1.2.0/index.html#predicates-attributes-and-handlers,并使用以下重写标记: