Struts2 study notes PreResultListener listener

Source: Internet
Author: User


1. Description
 
PreResultListener is a listener interface, which can be called back between physical views after the Action is completed and transferred to the system.
The Struts2 application can add the PreResultListener listener for the Action and interceptor, and add the PreResultListener listener through the addPreResultListener () method of ActionInvocation. Once the PreResultListener listener is added to the Action, the listener can call back the beforeResult () method of the listener before the application is transferred to the actual physical view. Once the interceptor is added with the PreREsultListener listener, the listener applies to all the actions intercepted by the interceptor.
 

2. Instance
 

The code is as follows: Copy code
Public class myAction extends Action
{
Public String execute ()
       {
ActionInvocation invocation = ActionContext. getContext (). getActionInvocation ();
Invocation. addPreResultListener (new PreResultListener ()
              {
Public void beforeResult (ActionInvocation invacation, String resultCode)
                     {
// Method body write the listener business logic we need to process
// The above parameter resultCode is the request sent by the foreground (that is, the logical name of the Action)
                     }
});
       }
}

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.