Reputation: 2638
I have added Struts2 interceptor, There I want to change calling action if some logic trigger. Currently I can change redirect JSP file after invoke the action. But I need to change the calling action before invoke the the action. Is there any way to invoke different action?
Thank You.
Upvotes: 1
Views: 2688
Reputation: 20323
Your intercept method as per your comments would look something like this:
public String intercept(ActionInvocation actionInvocation) throws Exception {
final ActionContext actionContext = ActionContext.getContext();
final HttpServletRequest httpServletRequest = (HttpServletRequest) actionContext.get(HTTP_REQUEST);
HttpSession httpSession = httpServletRequest.getSession(false);
UserObject userObject = session.getAttribute("User"); //Check for user information, this is just a dummy
if(isSpecificUser(userObject)){
return "SpecificAction";
}
return actionInvocation.invoke();
}
SpecificAction
should be present in your configuration file.
Upvotes: 3