我有 Struts 2 动作CustomerAction.java
,命名为 folderHierarchy/actions/customer
(customer
在namespace
此处)。从这个动作类中的一个方法,我重定向到我的旧动作类
Result
映射是:
@Result(name = "redirectTo", location = "#parameters.redirectLocation", type = "redirect") })
其中的#parameters.redirectLocation
值为
/customerhome.do?custIdId=200
Action
方法是:
@Action(value = "CustomerAction!redirectToPage")
public String redirectToLocation() {
return "redirectTo";
}
但问题是 strutscustomer
在重定向位置之前自动添加当前操作命名空间(即)。
所以而不是重定向到
/myWebApp/customerhome.do?custIdId=200
,
Struts 2 重定向到
/myWebApp/customer/customerhome.do?custIdId=200
我不明白为什么要添加customer
名称空间以及如何摆脱它?
我也试过:
@Result(name = "redirectTo", location = "#parameters.redirectTo", type = "redirect", params = { "namespace", "/" }) })
但它也没有用。
另一个观察结果是:
什么有效:
@Result(name = ComposeMessageCrudAction.REDIRECT_TO, location = "/customerhome.do?custIdId=200", type = "redirect") })
什么不起作用:
@Result(name = "redirectTo", location = "#parameters.redirectLocation", type = "redirect") })
其中的#parameters.redirectLocation
值为
/customerhome.do?custIdId=200
我不明白为什么第二种方法不起作用以及为什么它customer
之前添加了命名空间
/customerhome.do?custIdId=200