When configuring a package, you can specify the default interceptor for it. Once a default interceptor is specified for a package, if the action in the package does not explicitly specify the interceptor, the default interceptor will take effect. Note: once an interceptor is explicitly applied to the action in the package, the default interceptor does not work. If the action needs to use the default interceptor, you must manually configure the reference of the interceptor.
ConfigurationDefault interceptorUse<Default-interceptor-ref name = "XXX".../>This element is used as a child element of the <package.../> element, and the default interceptor is configured for all actions in the package. Only one default interceptor can be specified for each package.
<Package name = "package name"> <interceptors> <Interceptor... /> <Interceptor-stack... /> </interceptors> <default-interceptor-ref name = "Interceptor name or interceptor stack name"/> <action... /> </package>
At this point, we can see that the configuration elements related to the interceptor are as follows:
Elements related to interceptor Configuration
Element |
Description |
<Interceptors.../> |
This element is used to define the Interceptor. All interceptor and interceptor stacks are defined under this element. This element contains the <Interceptor.../> and <Interceptor-stack.../> sub-elements, Used to define the interceptor and interceptor stack respectively |
<Interceptor.../> |
This element is used to define a single Interceptor. You need to specify two attributes: Name and class. |
<Interceptor-stack.../> |
This element is used to define the interceptor stack and can contain multiple <Interceptor-ref.../> sub-elements |
<Interceptor-ref.../> |
This element references an interceptor or interceptor stack, indicating that the application specifies the interceptor. Only one name attribute is required. |
<Param.../> |
This element is used to specify parameters for the interceptor. |
<Default-interceptor-ref.../> |
This element configures the default interceptor for the specified package. This element is used as a child element of the <package.../> element. |