今天有空学习下页面缓存,我的例子是最简单的。。。:
1、下载ehcache-core ehcache-web jar包。
2、web.xml:
<filter>
<filter-name>SimplePageCachingFilter</filter-name>
<filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SimplePageCachingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3、ehcache.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<cache name="SimplePageCachingFilter" maxElementsInMemory="1"
eternal="false" timeToIdleSeconds="20" timeToLiveSeconds="20"
overflowToDisk="true" maxElementsOnDisk="10000000" diskPersistent="false"
diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
</ehcache>