程序代码: |
<taglib> <taglib-uri>oscache</taglib-uri> <taglib-location>/WEB-INF/classes/oscache.tld</taglib-location> </taglib> |
程序代码: |
log4j.rootLogger=DEBUG,stdout,file log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=[start]%d{yyyy/MM/dd/HH:mm:ss}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD]n%c[CATEGORY]%n%m[MESSAGE]%n%n log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=oscache.log log4j.appender.file.MaxFileSize=100KB log4j.appender.file.MaxBackupIndex=5 log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=[start]%d{yyyy/MM/dd/HH:mm:ss}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD]n%c[CATEGORY]%n%m[MESSAGE]%n%n log4j.logger.org.apache.commons=ERROR log4j.logger.com.opensymphony.oscache.base=INFO commons-logging.properties文件内容为 org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog |
程序代码: |
<%@pageimport="java.util.*"%> <%@tagliburi="oscache"prefix="cache"%> <html> <body> 没有缓存的日期:<%=newDate()%><p> <!--自动刷新--> <cache:cachetime="30"> 每30秒刷新缓存一次的日期:<%=newDate()%> </cache:cache> <!--手动刷新--> <cache:cachekey="testcache"> 手动刷新缓存的日期:<%=newDate()%><p> </cache:cache> <ahref="cache2.jsp">手动刷新</a> </body> </html> |
程序代码: |
<cache:cachetime="30"scope="session"> ... </cache:cache> |
程序代码: |
<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>CacheFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> |