在wildfly-8.2.0.Final中允许G zip压缩

时间:2016-07-19 11:11:43

标签: maven gzip wildfly-8

我在wildfly-8.2.0.Final上运行我的java项目,我想为Web内容(js,css,jsp等)启用G-zip压缩,如何实现它。

1 个答案:

答案 0 :(得分:1)

我完成了,我们需要像这样更改standalone.xml 搜索然后进行如下更改

<subsystem xmlns="urn:jboss:domain:undertow:1.2">
            <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"/>
                    **<filter-ref name="gzipFilter" predicate="regex[pattern='(?:application/javascript|text/css|text/html)(;.*)?', value=%{o,Content-Type}, full-match=true]"/>**
                    <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"/>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
                **<gzip name="gzipFilter"/>**
            </filters>
        </subsystem>

(粗体文字是更改)