Redirect 识别Struts2接收器中的重定向/转发动作

Redirect 识别Struts2接收器中的重定向/转发动作,redirect,struts2,action,interceptor,Redirect,Struts2,Action,Interceptor,我一直在寻找一种方法来识别Struts 2操作,这些操作在Interceptor中属于“Redirect/Forward”类型,这样我就可以为特定类型的操作添加一些通用代码 Struts2中有没有办法找到它是什么类型的动作 提前感谢。没有所谓的重定向操作或转发操作,您需要的是重定向结果类型 在您的拦截器中,您有一个ActionInvocation的实例传递给您的intercept方法,您可以从ActionInvocation对象获得结果,然后根据您的用例进行检查。列出了不同的结果 public

我一直在寻找一种方法来识别Struts 2操作,这些操作在Interceptor中属于“Redirect/Forward”类型,这样我就可以为特定类型的操作添加一些通用代码

Struts2中有没有办法找到它是什么类型的动作


提前感谢。

没有所谓的重定向操作或转发操作,您需要的是重定向结果类型

在您的拦截器中,您有一个
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.
}