简体   繁体   English

将请求从struts2动作转发到非struts 2动作?

[英]Forward the request to non struts 2 action from struts2 action?

I have legacy appication which is using proprieatary framework which is more or less like struts 1.2.Now we have started using struts 2. At lot of places i am submitting the html form to old actions from jsp. 我有一个使用专有框架的遗留应用,该专有框架或多或少类似于struts 1.2。现在我们已经开始使用struts2。在很多地方,我正在将html表单提交给jsp的旧操作。 What i want is first request goes to my new struts 2 action and then i forward the request to my legacy action from there so that i get all source request paramters in destination legacy action.I know there is result type redirect(as mentioned below) but that wont forward the source request paramters to legacy action. 我想要的是第一个请求转到我的新struts 2操作,然后从那里将请求转发到我的旧操作,以便我在目标旧操作中获取所有源请求参数。我知道结果类型重定向(如下所述)但这不会将源请求参数转发给旧操作。

@Result(name = "displayCustomer",
        location = "legacyAction.do", type = "redirect")


@Action("display-customer!displayCustomer")
  public String displayCustomer() {
    return "displayCustomer";
  }

I did not find any type as "forward" similar to redirect. 我没有找到任何类似于重定向的“转发”类型。 I am not sure how to forward the request to non struts 2 action from struts 2 action? 我不确定如何将请求从struts 2动作转发到非struts 2动作?

you can simply forward the control to respective page based on your result type for example SUCCESS .You can use chain result type for executing two different action at one time. 您可以根据结果类型(例如SUCCESS)简单地将控件转发到相应的页面。您可以使用链式结果类型一次执行两个不同的操作。

It will look like this: 它看起来像这样:

using XML configuration 使用XML配置

    <action class="your_action_path" name="your_action_name" method="your_target_method">
                <result type="chain">your_legacy_action</result>
    </action>

     //Then your_legacy_action_mapping here

<action class="your_legacy_action_path" name="your_legacy_action_name" method="your_target_method">
                <result>your_target_success_page</result>
    </action>

in struts2 default result type is configured as 'dispatcher'. 在struts2中,默认结果类型配置为'dispatcher'。 which 'forwards' the request. 哪个“转发”请求。 try setting the type="dispatcher". 尝试设置type =“ dispatcher”。 Check your struts configuration whether 'dispatcher' result type has been configured properly. 检查您的struts配置是否正确配置了“ dispatcher”结果类型。 It should look like something below. 它应该看起来像下面的东西。

<result-types>
   <result-type name="dispatcher" default="true"
                class="org.apache.struts2.dispatcher.ServletDispatcherResult" />
</result-types>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM