Struts2 uses 14-interceptor 4-custom interceptor

Source: Internet
Author: User

 

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.

 

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.