Struts2 Interceptor (2): configure the default interceptor

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.