我正在做一个使用 Struts 1.3 的小项目,我遇到了以下问题。
在 Action
中发生一些业务逻辑后,我想将控制转发给映射到 struts-config.xml
中的另一个 Action。
通常这是我解决这个问题的方式:
struts-config.xml
<action path="/boardCreate" type="com.example.BoardCreateAction" name="BoardCreateForm" input="/board.jsp">
<forward name="success" path="/board.do" redirect="true" />
</action>
Java Action 类
return mapping.findForward("success");
这将重定向到也映射到那里的 board.do
操作。
我的问题是我想将控件重定向到如下内容:
<forward name="success" path="/board.do?id=1" redirect="true" />
注意 id=1 参数。除了为此重建我自己的行动之外,还有其他方法吗?我找不到任何讨论此事的文件。谢谢!
最佳答案
ActionRedirect redirect = new ActionRedirect(mapping.findForward("success"));
redirect.addParameter("id", theId);
return redirect;
参见 http://tool.oschina.net/uploads/apidocs/struts-1.3.10/org/apache/struts/action/ActionRedirect.html
关于java - Struts 1.3 Action 转发参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10776051/