2014-12-16 2 views
2

나는 broadleaf에서 정적 파일 (js, css, html 및 images)에 대해 gzip 압축을 사용하는 방법을 알고 싶습니다. 나는 의 web.xml에서 프로젝트의 파일을 다음을 시도하고 나는 또한 org.eclipse.jetty.servlets.GzipFilter 클래스에 해당 종속성이있어 :부두에서 gzip 압축을 사용하려면 어떻게해야하나요?

<filter> 
     <filter-name>GzipFilter</filter-name> 
     <filter-class> org.eclipse.jetty.servlets.GzipFilter</filter-class> 
     <init-param> 
     <param-name>mimeTypes</param-name> 
     <param-value>text/html,text/plain,text/xml,application/xhtml+xml,text/css,application/javascript,image/svg+xml</param-value> 
     </init-param> 
    </filter> 

    <filter-mapping> 
     <filter-name>GzipFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

질문 내가 나를 포기하지 않았다 스택 오버플로에 seeen 한을 대답은 새로운 질문을 올리는 것입니다. 내 프로젝트에서 나는 부두-web.xml의이 같은이 : 나는 부두-web.xml에 파일에 필터 매핑을를 추가하려고하면

<?xml version="1.0"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> 

<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 

    <Set name="contextPath">/</Set> 

</Configure> 

을, 나는 무엇입니까 필터 태그에 익숙하지 않은 오류입니다.

HTML/JS/CSS 파일에 추가/수정해야 할 사항이 있습니까?

답변

0

사용 init-paramwebdefault.xml에서 :

<init-param> 
    <param-name>gzip</param-name> 
    <param-value>true</param-value> 
</init-param> 

또는 처리기를 추가 jetty.xml에 :

<?xml version="1.0"?> 
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> 

<!-- =============================================================== --> 
<!-- Mixin the GZIP Handler           --> 
<!-- This applies the GZIP Handler to the entire server    --> 
<!-- If a GZIP handler is required for an individual context, then --> 
<!-- use a context XML (see test.xml example in distribution)  --> 
<!-- =============================================================== --> 

<Configure id="Server" class="org.eclipse.jetty.server.Server"> 
    <Call name="insertHandler"> 
    <Arg> 
     <New id="GzipHandler" class="org.eclipse.jetty.server.handler.gzip.GzipHandler"> 
     <Set name="minGzipSize"><Property name="jetty.gzip.minGzipSize" deprecated="gzip.minGzipSize" default="2048"/></Set> 
     <Set name="checkGzExists"><Property name="jetty.gzip.checkGzExists" deprecated="gzip.checkGzExists" default="false"/></Set> 
     <Set name="compressionLevel"><Property name="jetty.gzip.compressionLevel" deprecated="gzip.compressionLevel" default="-1"/></Set> 
     <Set name="inflateBufferSize"><Property name="jetty.gzip.inflateBufferSize" default="0"/></Set> 
     <Set name="syncFlush"><Property name="jetty.gzip.syncFlush" default="false" /></Set> 

     <Set name="excludedAgentPatterns"> 
      <Array type="String"> 
      <Item><Property name="jetty.gzip.excludedUserAgent" deprecated="gzip.excludedUserAgent" default=".*MSIE.6\.0.*"/></Item> 
      </Array> 
     </Set> 

     <Set name="includedMethodList"><Property name="jetty.gzip.includedMethodList" default="GET" /></Set> 
     <Set name="excludedMethodList"><Property name="jetty.gzip.excludedMethodList" default="" /></Set> 

<!-- 
     <Set name="includedMethods"> 
      <Array type="String"> 
      <Item>GET</Item> 
      </Array> 
     </Set> 
     <Set name="includedPaths"> 
      <Array type="String"> 
      <Item>/*</Item> 
      </Array> 
     </Set> 
     <Set name="excludedPaths"> 
      <Array type="String"> 
      <Item>*.gz</Item> 
      </Array> 
     </Set> 
     <Call name="addIncludedMimeTypes"> 
      <Arg><Array type="String"> 
      <Item>some/type</Item> 
      </Array></Arg> 
     </Call> 
     <Call name="addExcludedMimeTypes"> 
      <Arg><Array type="String"> 
      <Item>some/type</Item> 
      </Array></Arg> 
     </Call> 
--> 

     </New> 
    </Arg> 
    </Call> 
</Configure> 

참조

관련 문제