Reputation: 9621
Does spring mvc have the concept of events firing before/after a controller action?
I am currently using a filter, but I could also inherit from a basecontroller for specific sections of my website and use before/after events if they exist.
So I mean I can create an event that fires just before a controller's action fires, or an event that fires after.
Upvotes: 3
Views: 2916
Reputation: 1943
I think you are looking for interceptors. I don't know what strategy you are using for routing you requests to your controller methods, so I assume you are using annotations. Then, here is how you could put your interceptor on the stack:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="loginInterceptor"/>
</list>
</property>
</bean
Where loginInterceptor is the id of a bean declared in your application context which implements the interface org.springframework.validation.Validator
Upvotes: 2