Skip to main content

Custom Interceptor

Learn Custom Interceptor (Advanced Spring MVC, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes HandlerInterceptor runs code around controller execution: preHandle before, postHandle after the handler and afterCompletion after the response. Register it with InterceptorRegistry.addInterceptor in WebMvcConfigurer.addInterceptors , with addPathPatterns and excludePathPatterns . Veto : preHandle returns false to stop the chain, so the controller is not called.

More lessons in Advanced Spring MVC