配置一个filter
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<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>/index.jsp</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
配置ehcache.xml cache的name必须为SimplePageCachingFilter,不然会报拦截器加载失败及空指针
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd">
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10"
eternal="false"
timeToIdleSeconds="5"
timeToLiveSeconds="10"
overflowToDisk="true"
/>
<cache
name="SimplePageCachingFilter"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
timeToLiveSeconds="2"
memoryStoreEvictionPolicy="LFU"
/>
<!-- timeToLiveSeconds两秒 -->
</ehcache>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
out.println(new Date());
%>
</body>
</html>
必须有common-logging.jar和log4j.jar
下面是完整代码
分享到:
相关推荐
三个ehcache的小demo,两个web程序,一个纯java,java项目是采用注解和xml配置,是后台缓存。一个web项目是注解配置,后台缓存;另一个是拦截器配置,前天缓存
自定义实现SPring--ehcache后台缓存实现!
Spring Boot 过滤器和拦截器 Spring Boot 全局异常处理 Spring Boot 参数校验 Spring Boot OpenAPI 文档集成 Spring Boot 集成 Mybatis Spring Boot 集成 Mybatis-plus Spring Boot JPA - 全自动 ORM Spring Boot ...
里面有目前的流行的前台springmvc框架,持久化层采用hibernate,安全方面采用shiro框架,页面风格采用bootstrap,同时里面还集成了javamelody监控,ehcache缓存机制,druid连接池管理,以及spring事务管理,spring...
实现动态查询,使用了自定义注解,连接数据库表,为了保证数据的安全性,在SpringMVC中配置了自定义拦截器interceptor,过滤非法访问后台的请求类型。 因为主页会有大量的人员访问,所以为了降低服务器的压力,避免...
CMS项目的相关资源:包含后台图片管理,后台职位管理,用户登录,用户注册,用户邮箱激活,前台展示,用户登录,高级查询。 项目的主要技术: web框架spring+springmvc+springjdbc ...Spring拦截器—后台访问安全
* 拦截器 HandlerInterceptor * 系统启动任务 CommandLineRunner * 集成 Junit 单元测试 * 读取系统环境变量 * 使用自定义 properties * 改变默认包扫᧿ * 自定义启动 Banner * 导入 spring XML 配置文件 * 热部署 *...
并将该用户的资源权限保存到ehcache缓存中,自定义拦截器,防止用户没有登陆,或没有权限直接拼接url访问!资源树,利用的是ztree,并且完成了资源的回显,重新赋权的功能!按钮资源使用的是自定义标签进行显示或...
1.25 Spring Boot 拦截器HandlerInterceptor 1.26 Spring Boot启动加载数据CommandLineRunner 1.27 Spring Boot环境变量读取和属性对象的绑定 1.28 Spring Boot使用自定义的properties 1.29 改变自动扫描的包 1.30 ...
3、系统利用struts2 拦截器 判断用户是否登录哦 4、使用p6spy 打印出hibernate 中已经替换了占位符参数的sql语句,为hibernate的调试不在感到苦恼 系统部署我使用的ant 部署,代码包含ant部署文件 skyline\...
│ │ ├─ehcache.xml----------------ehcache缓存配置 │ │ │ └─webapp----------------web页面和静态资源存放的目录 │ 注:SpringBoot项目默认不支持将静态资源和模板(web页面)放到webapp目录,但是个人感觉...
配置druid数据源监视: ehcache二级缓存配置xml注解ftp服务; Excel相关处理; jmx监控MBean测试; ArchUnit参数验证;跨域处理; shiro权限控制;静态资源,“ /”映射服务启动注册到consul;并测试获取redis服务,...
Spring Boot中使用过滤器和拦截器 Spring Boot整合MyBatis通用Mapper和PageHelper 深入学习Spring Boot自动装配 深入学习Spring Boot中的SpringApplication Spring Boot配合Hibernate Validator参数校验 自定义...
该项目是基于SpringBoot2.1.3版本来实现的,算是比较新的。该项目中用到了SpringBoot2.0之后的拦截器,yml配置jsp,整合Mybatis-Plus,以及使用了其一对多,多对多的查询特性,还集成了Ehcache缓存技术等
文档内容 一、 Spring介绍 1 1.1、SpringBoot简介 1 1.2、系统要求: 1 1.3、SpringBoot和SpringMVC区别 1 1.4、SpringBoot和SpringCloud区别 2 ...12.7、SpringBoot整合拦截器 51 12.8、发布打包 52
主版本就是apache log4j2的集成和spring标准全套(含日志、拦截器、过滤器、工具类)、空工程项目。 适合快速检出。 algorithm 使用Java语言实现一些算法,如果要查看C语言实现相关算法,请参照。 appcache 应用级...
- Spring Boot 基础知识,包括SpringBoot起步、配置详解、aop、filter、拦截器、监听、启动器、全局异常处理、外部Tomcat启动、HTTPS、监控 等。 - springboot-data - Spring Boot 数据库操作,包括SpringJDBC、...
eclipse 开发的作品,整合spring mvc mybatis ExtJS6,实现漂亮的管理后台; 主要技术说明:完善了CURD的功能;健全的权限管理;缓存工厂的使用,默认使用...完善了Cookies登录的拦截器功能(权限控制在这里完成)。
5. 利用ehcache框架对经常调用的查询进行缓存,提升运行速度,具体请见ConstantFactory类中@Cacheable标记的方法。 6. controller层采用map + warpper方式的返回结果,返回给前端更为灵活的数据,具体参见...