【问题标题】:Identifying Redirect/Forward Action in Struts2 Incerceptor识别 Struts2 拦截器中的重定向/转发动作
【发布时间】:2012-06-05 05:36:18
【问题描述】:

我一直在寻找一种方法来识别在 Interceptor 中属于“重定向/转发”类型的 Struts 2 动作,以便我可以为该特定类型的动作添加一些通用代码。

Struts2 中有什么方法可以找到它是什么类型的 Action 吗?

提前致谢。

【问题讨论】:

    标签: redirect struts2 action interceptor


    【解决方案1】:

    没有什么叫做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.
    }
    

    【讨论】:

      猜你喜欢
      • 2012-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-20
      • 2014-12-23
      • 1970-01-01
      • 2014-03-31
      相关资源
      最近更新 更多