我一直在寻找一种方法来识别拦截器中类型为“重定向/转发”的 Struts 2 操作,以便我可以为该特定类型的操作添加一些通用代码。
在 Struts2 中有什么方法可以找到它是什么类型的 Action 吗?
提前致谢。
我一直在寻找一种方法来识别拦截器中类型为“重定向/转发”的 Struts 2 操作,以便我可以为该特定类型的操作添加一些通用代码。
在 Struts2 中有什么方法可以找到它是什么类型的 Action 吗?
提前致谢。
没有什么叫做 RedirectAction 或 ForwardAction,你需要的是 Redirect Result Type。
在您的拦截器中,您有一个ActionInvocation
传递给您的intercept
方法的实例,您可以从ActionInvocation
对象获取结果,然后根据您的用例进行检查。此处列出了不同的结果
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.
}