Inside Interceptor.intercept (), how can I find out if the action is completed?

I use some things in my Struts-based application using interceptors, and I am embarrassed about how their life cycle works. According to the Struts docs ( "Interceptors" , "Writing Interceptors" and "Big Picture" ), it should work something like this:

Firstinterceptor
  NextInterceptor
    Lastinterceptor
      Action
      Result
    Lastinterceptor
  NextInterceptor
Firstinterceptor

which makes sense, but I come across how to distinguish an interceptor call made before an action from one executable file after rendering the result (I skip PreResultListenerhere). If I run the debugger, I get two calls intercept()and cannot find anything obvious in ActionInvocationwhich I passed. ( Update : This part was a lot of confusion at my end, and I was able to answer my question below as soon as I received it)

The Big Picture page speaks a little vaguely about the called "before" and "after" "sentences," but I don’t know. I don’t know what to do about it:

[...]

This includes invoking any interceptors (before clause) before invoking the action itself.

[...]

( , after).

[...]

( : - )

+2
1

:

public class MyInterceptor implements Interceptor {

    public String intercept(ActionInvocation invocation) {
        /*
        This is before Action.execute(),
        and before all interceptors down the stack
        */

        String code = invocation.invoke();

        /*
        This is after Action.execute(),
        the result rendering and all
        interceptors down the stack,
        but before the interceptors
        higher up in the stack.
        */

        return code;
    }

}

( , " ", , , . .)

+2

Source: https://habr.com/ru/post/1715793/


All Articles