oscache的使用

OSCache由OpenSymphony设计,它是一种开创性的JSP定制标记应用,提供了在现有JSP页面之内实现快速内存缓冲的功能。

1.从http://www.opensymphony.com/oscache/download.html下载合适的OSCache版本.就现在最新版本oscache-2.4.1-full.zip.

解压缩下载的文件到指定目录

2. 将oscache-2.4.1.jar,commons-logging.jar复制到/WEB-INF/lib,将oscache.properties,oscache.tld拷到src目录下

3.在web.xml加上oscache.tld的配置:

<jsp-config> 

<taglib> 

   <taglib-uri>oscacheTag</taglib-uri> 

    <taglib-location>/WEB-INF/class/oscache.tld</taglib-location> 

</taglib> 

</jsp-config> 

4.如果需要对特定的页面进行过滤,使用oscache过滤器,在web.xml中添加

<filter> 

<filter-name>CacheFilter</filter-name> 

<filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class> 

</filter> 

<filter-mapping> 

<filter-name>CacheFilter</filter-name> 

<!--对所有jsp页面内容进行缓存--> 

<url-pattern>*.jsp</url-pattern> 

</filter-mapping> 

5.在jsp页面中引用oscache标签

<%@ taglib  uri="oscacheTag" prefix="oscache" %> 

也可以使用如下方式进行引用: 

<%@ taglib  uri="/WEB-INF/classes/oscache.tld" prefix="oscache" %> 

在jsp页面中使用oscache标签: 

<oscache:cache> 

<% out.print("这是在缓存内容"); %> 

</oscache:cache> 


posted @ 2013-03-17 15:02  IT_熊  阅读(216)  评论(0编辑  收藏  举报