Я пытаюсь включить сжатие gzip на Jetty 9. Я не хочу настраивать его в своем web.xml, поэтому на основе документации Jetty я настроил переопределяющую сеть. XML. Я не использую Jetty во встроенном режиме, а в качестве контейнера.Как включить GZIP для Jetty 9
В моей папке {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>
В 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>
Jetty, кажется, чтобы загрузить этот штраф, но Сжатие gzip не применяется ни к одному из ответов. Я говорю, что Jetty загрузила этот штраф, потому что раньше, когда я пытался поместить override-web.xml
в папку webapps, Jetty жаловался.
Я рассмотрел различные вопросы здесь, и никто из них, похоже, не ответил на это. Любая помощь приветствуется.
Вы желающей опыт Servlet 2.5 на Jetty 9? (просто спрашивая, как ваш override-web.xml объявляет 2.5, и мы не знаем, что ваш cc.war объявлен как) –
web.xml в моем cc.war объявляет версию = 2.5. – IceMan