What is 1.actionInvocation?
Actioninvocation is the caller of the action. Actioninvocation is responsible for the dispatch of a series of elements, such as interceptor, action, and result, during action execution.
Understanding actioninvocation You need to have a thorough understanding of the action invocation process:
http://tech.ddvip.com/2009-01/1232090919106049.html
It's still very clear to say.
2.ActionInvocation what?
Interceptor can completely change the action behavior by actioninvocation: Do not let it execute, change the return value, or even fine-grained operation of the action method
View Actioninvocation's API, he has Getactionproxy (), Getresultcode (); Getactioncontext ();
actionproxy constructs the execution environment in action, Actionproxy provides the configuration, parameters, and so on when the action executes, and, of course, the entrance to the action call.
Public String intercept (actioninvocation invocation) throws Exception {
Map session= Invocation.getinvocationcontext (). getsession ();
String Actionname=invocation.getproxy (). Getactionname ();
String Methodname=invocation.getproxy (). GetMethod ();
} You have this method when you write the filter, if you do not inherit extends Abstractinterceptor
Example:
Public String intercept (actioninvocation invocation) throws exception{
Actioncontext CTX = Invocation.getinvocationcontext ();
If the requested action exists within the appropriate scope, return directly to the Intercept method and invoke the action to execute
for (String action:whitelist) {
if (Ctx.getname (). Equals (action)) {
return Invocation.invoke ();
}
}
If the requested action is not within the defined range, see if you are logged in and have permission to do this action
HttpSession session = Servletactioncontext.getrequest (). GetSession ();
if (Session.getattribute ("session_admin") = = null) {
Session.setattribute ("Sessionerrormessage", "Please login to the system first.") ");
return "LoginError";
}
If the requested action is not within the scope, but is already logged in, the action request is executed directly
return Invocation.invoke ();
}