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.
Categories: Java

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Apache Ant

Apache Ant basic tasks

In the previous post, we have learned what is Apache Ant, its features and an example to create simple build file. This post will guide you other basic ant tasks that are frequently used to create Read more…

Apache Ant

Apache Ant : Java Build Tool

Apache Ant is a Java library and command-line tool to automate the repetitive tasks and helps to build software. Ant is flexible and does not impose coding conventions. It supplies a number of built-in tasks allowing Read more…

Java

Servlet filter vs Spring Interceptor

Servlet Filter Spring Interceptor A Servlet Filter is used in the web layer only, you can’t use it outside of a web context. Interceptors can be used anywhere. For authentication of web pages, you would Read more…