Strust2AOP learning notes

Source: Internet
Author: User
Strust is equivalent to an empty container, and the built-in interceptor completes most of the operations on the framework. The struts2 interceptor is pluggable. To use an interceptor, you only need to apply it to the configuration file. If you do not need it, cancel it in the configuration file. Configure the interceptor Syntax: interceptor-stackname

Strust is equivalent to an empty container, and the built-in interceptor completes most of the operations on the framework. The struts2 interceptor is pluggable. To use an interceptor, you only need to apply it to the configuration file. If you do not need it, cancel it in the configuration file. Configure the interceptor Syntax: interceptor-stack name =

Strust is equivalent to an empty container, and the built-in interceptor completes most of the operations on the framework. The struts2 interceptor is pluggable. To use an interceptor, you only need to apply it to the configuration file. If you do not need it, cancel it in the configuration file.

Configure the interceptor Syntax:

......


When the interceptor parameter is specified, either it is defined or used in the struts. xml file.

Dynamic Parameters

If different parameter values are specified for the same parameter at two times, the parameter values specified when the interceptor is used are used.

Strust2 itself has a default interceptor stack. As long as the package of action inherits from struts-default, the interceptor stack is used for action by default. However, if a custom interceptor is used in an action, the default interceptor does not take effect unless it is declared. Only one default interceptor can be specified for each package.

When you implement your own interceptor class and call the intercept (ActionInvocation invocation) method, if a string is directly returned, the system will jump to the actual view corresponding to the logical view, instead of calling the intercepted action. The ActionInvocation parameter contains the reference of the intercepted Action. You can call

Invocation.invoke(); actionactionactionaction(), or the action.exe cute () method.

When using an interceptor to perform a user permission check, it is usually done by tracking HTTPSession and accessing the attributes in the session through ActionContext. Similar code is as follows:

Map session = ActionContext. getContext (). getSession ();

String userId = session. get ("user ");


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.