oscache的页面缓存


oscache的页面缓存

oscache的下载地址:
http://www.opensymphony.com/oscache/

1、将jar包拷贝到项目的lib中
2、修改web.xml文件,加入如下几行:

<filter>
   <filter-name>encodingFilter</filter-name>
   <filter-class>
    org.springframework.web.filter.CharacterEncodingFilter
   </filter-class>
   <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
   </init-param>
   <init-param>
    <param-name>forceEncoding</param-name>
    <param-value>true</param-value>
   </init-param>
</filter>


<filter>
   <filter-name>cacheFilter</filter-name>
   <filter-class>
    com.opensymphony.oscache.web.filter.CacheFilter
   </filter-class>
   <init-param>
    <param-name>time</param-name>
    <param-value>60</param-value>
   </init-param>
   <init-param>
    <param-name>scope</param-name>
    <param-value>session</param-value>
   </init-param>
</filter>

<filter-mapping>
   <filter-name>encodingFilter</filter-name>
   <url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
   <filter-name>encodingFilter</filter-name>
   <url-pattern>*.jsp</url-pattern>
</filter-mapping>

<filter-mapping>
   <filter-name>cacheFilter</filter-name>
   <url-pattern>*.do</url-pattern>
</filter-mapping>

其中特别要注意encode的filter要放在cache filter前面,这样就不会有乱码问题

3、拷贝oscache.properties到classpath下面

你可能感兴趣的:(jsp,xml,Web,cache)