我正在尝试在Jetty 9上启用gzip压缩.我不想在我的web.xml中配置它,因此基于Jetty文档我已经配置了override-web.xml.我不是在嵌入模式下使用Jetty,而是作为容器使用Jetty.
在我的{jetty.home}/webapps文件夹中,我是我的战争档案 - cc.war.我还定义了一个cc.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<!-- ==================================================================
Configure and deploy the test web application in $(jetty.home)/webapps/test
Note. If this file did not exist or used a context path other that /test
then the default configuration of jetty.xml would discover the test
webapplication with a WebAppDeployer. By specifying a context in this
directory, additional configuration may be specified and hot deployments
detected.
===================================================================== -->
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration : -->
<!-- + contextPath -->
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/</Set>
<Set name="war"><Property name="jetty.webapps"/>/cc.war</Set>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Optional context configuration -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- <Set name="extractWAR">true</Set>
<Set name="copyWebDir">false</Set>
-->
<!--<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>-->
<Set name="overrideDescriptor"><Property name="jetty.webapps" default="."/>/cc.d/override-web.xml</Set>
</Configure>
Run Code Online (Sandbox Code Playgroud)
在cc.d文件夹中,我覆盖了web.xml,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<filter>
<filter-name>GzipFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
<init-param>
<param-name>methods</param-name>
<param-value>GET,POST</param-value>
</init-param>
<init-param>
<param-name>mimeTypes</param-name>
<param-value>text/html,text/xml,text/plain,text/css,text/javascript,text/json,application/x-javascript,application/javascript,application/json,application/xml,application/xml+xhtml,image/svg+xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
Jetty似乎加载这个很好,但gzip压缩不适用于任何响应.我说Jetty加载这个很好,因为早些时候我试图把它override-web.xml放在webapps文件夹中,Jetty抱怨.
我在这里经历了各种各样的问题,但是他们似乎都没有答案.任何帮助表示赞赏.
| 归档时间: |
|
| 查看次数: |
7620 次 |
| 最近记录: |