I know that this might be a silly question but can you please explain what are interceptors and how does it work in Spring? And why are they declared inside applicationcontext.xml. Plus how are they related to auditing? Thank you!
I think we need to first clarify what type of Interceptor you mean. There are many types of interceptors out there and not all of them are from Spring or Spring specific. And we need to clarify "Spring".
I am going to make some assumptions here. 1) You are using Spring MVC, which is the Web Layer technology that Spring can provide, and works in the Spring Framework/Container. Spring MVC does not necessarily have to be used to use Spring, you could just use the Spring Framework/Container.
An Interceptor in Spring MVC is just like a Servlet Filter. You can intercept calls to a Controller method, and have code in the interceptor run before and after your code in your controller to run.
You can define Interceptors for Spring MVC in your configuration file.
Again, what do you mean by auditing? auditing what? Is this just logging? And Interceptors can be used for auditing, but you define that yourself, not Spring. Meaning you implement your own auditing by creating your own Interceptor, or by other means.