拦截器使用流程
1.自己定义一个拦截器的类(规则)
继承HandlerInterceptorAdapter
类
实现HandlerInterceptor接口(接口中三个方法都是default修饰)
2.自定义类的方法需要重写
preHandle 预先处理(controller之前执行) SpringAOP前置
postHandle 请求后处理(controller之后执行) SpringAOP后置
afterCompletion 完成后处理(controller执行完毕后,最后执行)
3.配置ApplicationContext.xml文件