如何在使用type = redirect重定向到另一个动作时传递参数?

我需要将一个参数从一个动作传递给另一个动作,但会出现以下错误。如何在使用type = redirect重定向到另一个动作时传递参数?

Messages: 

There is no Action mapped for namespace [/Product/Product] and action name [desc] associated with context path [].

struts.xml的

<package name="MyProducts" extends="default" namespace="/Product/Find"> 

<result name="Desc" type="redirectAction">

<param name="actionName">../Product/desc</param>

<param name="id">${id}</param>

</result>

....

<package name="Product" extends="default" namespace="/Product">

..........

在第一个动作(在命名空间/产品/查找),我设置具有getter和setter的ID。

在第二个动作(在命名空间/产品)我有一个ID变量和getter和setter。

回答:

添加另一个../到您的地址试试这个../../Product/desc

我知道他的意思,我想我只需要回答你的问题不提供任何其他方法,

<result name="YOUR RESULT NAME" type="redirectAction"> 

<param name="actionName">desc</param>

<param name="namespace">/Product</param>

</result>

不要使用/前面的名称空间名称伪造/ /否则它不起作用。 要重定向到默认软件包中的操作,请使用/作为您的命名空间参数。

回答:

最好的选择是你可以在会话中使用会话对象设置变量,然后可以在重定向操作类中访问该会话。任何方式我只通过在重定向操作中传递变量来寻找答案。希望这对你有帮助。

以上是 如何在使用type = redirect重定向到另一个动作时传递参数? 的全部内容, 来源链接: utcz.com/qa/260695.html

回到顶部