我添加了Struts2拦截器,如果某些逻辑触发,我想更改调用操作。目前我可以在调用动作后更改重定向JSP文件。但我需要在调用操作之前更改调用操作。有没有办法调用不同的动作?
谢谢。
答案 0 :(得分:2)
根据你的意见你的截取方法看起来像这样:
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
应出现在您的配置文件中。