java将请求从struts2 action转发到非struts2 action?
我有一个遗留应用程序,它使用的是或多或少类似于struts 1.2的专有框架。现在我们已经开始了 使用struts 2。在很多地方,我从jsp向旧操作提交html表单。我想要的是第一个请求 到我的新struts 2操作,然后我将请求转发到我的遗留操作,以便在目标遗留操作中获得所有源请求参数。我知道有结果类型 重定向(如下所述),但不会将源请求参数转发到遗留操作
@Result(name = "displayCustomer",
location = "legacyAction.do", type = "redirect")
@Action("display-customer!displayCustomer")
public String displayCustomer() {
return "displayCustomer";
}
我没有发现任何类似于重定向的“转发”类型。我不知道如何从struts 2将请求转发给非struts 2操作 行动
# 1 楼答案
您只需根据结果类型将控件转发到相应的页面,例如SUCCESS。您可以使用链结果类型一次执行两个不同的操作
它将如下所示:
使用XML配置
# 2 楼答案
在struts2中,默认结果类型配置为“dispatcher”。“转发”请求。 尝试设置type=“dispatcher”。检查struts配置是否正确配置了“dispatcher”结果类型。它应该看起来像下面的东西