HandlerInterceptors can be mapped to specific URLs that you want to intercept. The following example shows an example XML context configuration. By default, the interceptor will intercept all handlers (controllers):
<mvc:interceptors>
<bean class="com.mastering.spring.springmvc.
controller.interceptor.HandlerTimeLoggingInterceptor" />
</mvc:interceptors>
We can configure precise URIs to be intercepted. In the following example, all handlers, except those with URI mapping starting with /secure/, are intercepted:
<mvc:interceptors>
<mapping path="/**"/>
<exclude-mapping path="/secure/**"/>
<bean class="com.mastering.spring.springmvc.
controller.interceptor.HandlerTimeLoggingInterceptor" />
</mvc:interceptors>