There are three methods to implement the Interceptor:
L implement the interceptor Interface
The interceptor interface has three methods:
Public interface interceptor extends serializable { Void destroy (); Void Init (); String intercept (actioninvocation Invocation) throws exception; } |
L inherit the abstractinterceptor abstract class
Abstractinterceptor implements the interceptor interface. However, this abstract class overwrites the "Destroy" and "init" methods, but does not perform any operations in the methods. It is mainly used for initialization or cleanup without any other operations.
L inherit the abstract class methodfilterinteceptor
Methodfilterinteceptor inherits the abstractinterceptor class, which is mainly used as an interceptor to filter the action method. There are two attributes in the Set: includemethods and excludemethods. includemethods indicates that the action method is included. The interceptor only blocks the containing method, and other methods are not blocked. You can configure multiple attributes separated by commas. Excludemethods indicates that the action method is not included. The interceptor does not intercept the non-contained method. Other methods can be configured with multiple methods separated by commas.
Note: If a method is in includemethods and excludemethods, includemethods takes precedence over excludemethods.