Interceptors are for mapping. The corresponding interception can be configured under mapping. Because of the common Mvc:annotation-driven configuration mapping and adapter, the interceptor is configured here with Mvc:interceptors.
1, a single mapping interceptor A, the definition of interceptors. The
implements the Interceptor interface.
B, configure interceptor
Intercept Queryuser.action, a specific (queryuser.action)
C, controller
d, test, console displays
2, multiple interceptors
is performed in the configuration order.
A, increase interceptor
B, configuration
1 before, 2 after
C, console
Prehandle executes Posthandle and aftercompletion in the order of the Interceptor in reverse order.
D, Analog interceptors are not released. Will interceptor 2, set not released.
test results.
Interceptor 2 interception, Interceptor 2 methods Posthandle and aftercompletion are not executed, Interceptor 1, performed aftercompletion.
As long as an interceptor is not released, the Posthandle will not be released.
Two interceptors are not released.
The
performs only 1 of the prehandle.
3, similar to the global interceptor.
Focus: Note the configuration path and the order in which the interceptors are understood.
Spring MVC Interceptor