There is another controller which extends this class and has a request mapping specified for one of its methods:
Now the issue here is that when dispatcher servlet redirects the request to the specific method (populateBeta in this case), i need to check for some request parameters modified in a separate interceptor class first.
So essentially i have to invoke the throwInterceptorExceptionForRedirection() method before the normal execution of populateBeta() begins.
The reason to eliminate the explicit call in the controller method is because i have multiple controllers & their mapped methods. All controllers extend the BaseController.
It would be great to have throwInterceptorExceptionForRedirection() executed before any URL mapped methods are invoked by the applicationcontext directly.
using point cuts as an option doesnt help as i need the HttpServletRequest object in throwInterceptorExceptionForRedirection().
Hi, you can try using filter with url pattern "/*" & you still have access to the request object. Let me know if you something better & specific in Spring for the mentioned task.
Apart from this I could really understand why exactly are using InterceptorExceptionForRedirection() ?.
cannot use filters as i am using the @ExceptionHandler annotation which is applicable only for the specific class(BetaController in this case). this annotation handles all exceptions in all the controllers.
but i am already invoking a interceptor on the "/*" url pattern, which essentially does some loading stuff. if any exception occurs there i am setting a flag in the request object which i can access in the controller.
when the flag is true i am deliberately throwing an exception in the controller, which is handled by the @ExceptionHandler annotation. thats the reason i need to invoke the throwInterceptorExceptionForRedirection() before any other invocations in the controller
i am achieving this but have to add throwInterceptorExceptionForRedirection() call as the first line of all child controllers, since i do not know a way to make spring invoke it automatically for every controller