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
- Custom HandlerMapping
- Custom HandlerAdapter
- Custom ViewResolver
- Custom Argument Resolver
- HandlerMethodArgumentResolver
- Custom Return Value Handler
- HandlerMethodReturnValueHandler
- Custom Formatter
- Custom Converter
- Custom Exception Resolver
- Custom Message Converter
- Custom Annotation
- Request Lifecycle Customization
- Mini Project: Asynchronous Requests: Callable, DeferredResult and Server-Sent Events