zoukankan      html  css  js  c++  java
  • Java web servlet 关于启用页面压缩的相关配置

    借助类,相关依赖:

    <!-- https://mvnrepository.com/artifact/net.sourceforge.pjl-comp-filter/pjl-comp-filter -->
    <dependency>
        <groupId>net.sourceforge.pjl-comp-filter</groupId>
        <artifactId>pjl-comp-filter</artifactId>
        <version>1.7</version>
    </dependency>

    在web.xml添加filter:

    <filter>
      <filter-name>CompressingFilter</filter-name>
      <filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>CompressingFilter</filter-name>
      <url-pattern>/*</url-pattern><!--对所有页面压缩-->
    </filter-mapping>

    更详细的例子:

    <filter>
            <filter-name>CompressingFilter</filter-name>
            <filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
            <init-param>
                <param-name>compressionThreshold</param-name><!-- 资源大小超过100byte的就被压缩 -->
                <param-value>100</param-value>
            </init-param>
            <init-param>
                <param-name>includeContentTypes</param-name><!-- 启动GZIP压缩的MIME类型 -->
                <param-value>text/html,text/xml,text/javascript,text/css,text/plain</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>CompressingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
  • 相关阅读:
    git 文件回退
    git reset
    开源
    android json js 算法 面试
    Android* 2.3.7
    Sqoop HBase Hadoop
    行业案例、技术



  • 原文地址:https://www.cnblogs.com/z-sm/p/5709545.html
Copyright © 2011-2022 走看看