Struts 1.3 action forward parameter
Asked Answered
D

1

18

I'm working on a little project which uses Struts 1.3 and I encountered the following problem.

After some business logic takes place in an Action i want to forward the control to another Action which is mapped in struts-config.xml.

Usually this is the way I'm solving this:

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 class

return mapping.findForward("success");

This will take make a redirect to the board.do action which is also mapped there.

My problem is that I want to redirect the control to something like:

<forward name="success" path="/board.do?id=1" redirect="true" />

Notice the id=1 parameter. Is this any other way except rebuilding my own action forward for this? I can't find any documentation debating this matter. Thanks!

Default answered 27/5, 2012 at 17:53 Comment(0)
D
42
ActionRedirect redirect = new ActionRedirect(mapping.findForward("success"));
redirect.addParameter("id", theId);
return redirect;

See http://tool.oschina.net/uploads/apidocs/struts-1.3.10/org/apache/struts/action/ActionRedirect.html

Dysphonia answered 27/5, 2012 at 18:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.