1. web.xml 文件配置
<!-- 配置页面缓存 --> <filter> <filter-name>oscache</filter-name> <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class> <init-param> <param-name>time</param-name> // 刷新时间 3600 是一个小时 <param-value>3600</param-value> </init-param> <init-param> <param-name>scope</param-name> <param-value>application</param-value> </init-param> </filter> <filter-mapping> <filter-name>oscache</filter-name> // 需要缓存的文件路径 <url-pattern>/items/list.do</url-pattern> </filter-mapping>
2. oscache.properties 文件
cache.memory=false // 不缓存到内存
cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener
cache.path=C:\\test // 缓存路径