shop--16.升级--添加拦截器 实现登录验证和权限验证

登录验证

店铺权限验证

拦截过滤

SpringMVC的Interceptor拦截是通过HandlerInterceptor实现的

  方式1:定义的Interceptor类实现HandlerInterceptor接口,或继承实现了HandlerInterceptor接口的类(HandlerInterceptorAdapter)  

    Boolean preHandle() 做预处理

    postHandle() controller调用之后,dispatcherServlet返回之前进行调用,对modelAndView对象进行处理

    afterCompletion()  dispatcherServlet渲染视图之后执行,进行资源的清理工作 

  方式2:实现Spring的WebRequestInterceptor接口,或继承实现了WebRequestInterceptor接口的类

在spring-web.xml加入interceptor配置

猜你喜欢

转载自www.cnblogs.com/SkyeAngel/p/9052354.html