考察 Filter、Interceptor、AOP 的执行顺序和职责。
Filter
Interceptor
HandlerInterceptor,在 Handler 执行前/后/完成后执行;能拿到 handler、ModelAndView,适合权限/日志/埋点。preHandle 返回 false 可中断;postHandle 在视图渲染前,afterCompletion 在完成后。AOP
顺序:Filter → Interceptor.preHandle → Controller → Interceptor.postHandle → afterCompletion → Filter;自调用会绕过 Interceptor/AOP。
题目与答案就在本页;收藏、批注和错题重练在应用内