Wednesday, December 21, 2016

Advantages of spring interceptor over servlet filter

Even filters can do the same things that interceptors can but interceptors can do more easily and more elegantly.

Interceptors are more coupled to the request/response cycle than filters.

Can inject other beans in the interceptor.

Can use more advanced mapping patterns (ant-style).

You have the target handler object (controller) available, as well as the result ModelAndView object.

It is a bean, so you can use AOP with it.


The main advantage of spring framework HanderInterceptor is - that they can intercept between Controller Handling and View Rendering and they are spring Beans so it is easy to access another spring bean.

No comments:

Post a Comment