Struts2 Review (5) interceptor Summary

Source: Internet
Author: User

1.

Interceptor (Interceptor ):

The Interceptor is the core of Struts2, and all functions of Struts2 are implemented through the interceptor.

2.

Interceptor Configuration

1) Write a class that implements the Interceptor interface.
2) define the interceptor in the struts. xml file.
3) Use interceptor in action
3.

Once the interceptor is defined and configured to the action, we need to add the default interceptor Stack: defaultStack at the end of the action.

4.

When defining the Interceptor, you can directly inherit the AbstractInterceptor abstract class (this class implements the Interceptor interface and implements the empty implementation of the init and destroy methods), and then implement its abstract method intercept.

5.

Method filter Interceptor (an interceptor that intercepts a specified method ).

6.

In the method filter interceptor, if neither the includeMethods parameter nor the execludeMethods parameter is specified, all methods are blocked, that is, all methods are considered includeMethods; if includeMethods is specified, only the methods in includeMethods are blocked. Methods not included in includeMethods are not blocked.



You are welcome to join us in the discussion and study!

Collect it by yourself!

Record and share, let you grow together! Welcome to my other blog; my blog address: http://blog.csdn.net/caicongyang







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.