HandlerInterceptor与Filter的区别
对比HandlerInterceptor和Servlet Filter的区别。
回答
苦行僧
Filter:Servlet规范,作用所有URL(含静态资源),DispatcherServlet前后执行。
Interceptor:Spring MVC框架,仅Controller方法,方法级别细粒度,可访问HandlerMethod。
选择:字符编码/CORS→Filter;权限校验/日志→Interceptor。
对比HandlerInterceptor和Servlet Filter的区别。
Filter:Servlet规范,作用所有URL(含静态资源),DispatcherServlet前后执行。
Interceptor:Spring MVC框架,仅Controller方法,方法级别细粒度,可访问HandlerMethod。
选择:字符编码/CORS→Filter;权限校验/日志→Interceptor。