【发布时间】:2012-06-05 05:36:18
【问题描述】:
我一直在寻找一种方法来识别在 Interceptor 中属于“重定向/转发”类型的 Struts 2 动作,以便我可以为该特定类型的动作添加一些通用代码。
Struts2 中有什么方法可以找到它是什么类型的 Action 吗?
提前致谢。
【问题讨论】:
标签: redirect struts2 action interceptor
我一直在寻找一种方法来识别在 Interceptor 中属于“重定向/转发”类型的 Struts 2 动作,以便我可以为该特定类型的动作添加一些通用代码。
Struts2 中有什么方法可以找到它是什么类型的 Action 吗?
提前致谢。
【问题讨论】:
标签: redirect struts2 action interceptor
没有什么叫做RedirectAction或ForwardAction,你需要的是Redirect Result Type。
在您的拦截器中,您有一个 ActionInvocation 实例传递给您的 intercept 方法,您可以从 ActionInvocation 对象获取结果,然后根据您的用例进行检查。列出了不同的结果here
public String intercept(ActionInvocation actionInvocation) {
//After invoking the action you can get the result of from ActionInvocation.
Result result = actionInvocation.getResult();
//As per your use case you can check against different types.
}
【讨论】: