Struts2 intercepter notes

Source: Internet
Author: User

I have never been very clear about the struts2 custom Interceptor (intercepter). I have studied it carefully today and finally understood it. The record's summary of the interceptor is as follows:

1: The Role of a custom interceptor is generally to achieve more system permission control;

2: The implementation of the custom interceptor can implement the intercepter interface, inherit the abstractinterceptor class, and override its intercept method;

3: permission management usage: first, obtain the login user from the session in the intercepter () method to determine whether the user has the permission to access the corresponding action, if you have the following permissions:

String result = invocation. Invoke ();

Return result;

Note that the returned result can also be abbreviated as return invocation. Invoke ();

Why is this returned? The answer is to call other intercepter for normal return (I am not very clear here)

When you determine that the user does not have the corresponding permission to access the corresponding method of the action to be accessed, you can directly return a string corresponding to the result set: for example, return "error ";

Find the corresponding result set in the corresponding result set (this is generally a global result set). If you find that you have no access permission, you do not need to call: Invocation. invoke.

 

Struts2 intercepter notes

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.