Struts Redirect w/Parameters Part 2
June 5, 2006
In an earlier post, I described a class to handle redirects in Struts and passing parameters along. That technique is not necessary; as of Struts 1.2.7, you can use the ActionRedirect class instead.
Here's a basic example from inside the execute method in an Action.
ActionRedirect redirect = new ActionRedirect(mapping.findForward("success")); redirect.addParameter("myparam","myvalue");
redirect.addParameter("something","fornothing");
redirect.addParameter("answer","42");
return redirect;
The ActionRedirect class is basically the same as my ForwardParameter class and is probably preferable.
June 5, 2006 at 9:01 am
[…] EDIT: This article has been superseded by a newer article. Posted by organicveggie Filed in Java, Web Development, Struts […]
June 27, 2006 at 7:23 am
ActionRedirect is something i have to build or it’s something i can include in my project?
I am working with struts and i am very new in the field.
June 27, 2006 at 2:49 pm
ActionRedirect is a class that is part of the Struts Action 1 framework as of Struts 1.2.7.
http://struts.apache.org/struts-action/struts-core/apidocs/org/apache/struts/action/ActionRedirect.html
September 18, 2006 at 11:41 am
thanks for the hint!
btw: previous part is indexed by google as first, so i was afraid i’d have to implement my own redirect class ;).
October 2, 2007 at 3:19 am
Exactly what I needed – many thanks!
March 31, 2008 at 8:03 pm
Great tip. Thanks for following up your previous post on this topic.
December 29, 2008 at 10:55 am
Nice artice…. This is what Im looking for….But the redirect uses GET method to send the parameters as it shows the query string in the browser… is there any way to send in POST method?
July 1, 2009 at 4:55 am
and just what are you supposed to do if your querystrings are dynamic or unknown at the time (ie: redirect to the sending url post completion)? You can’t do it. Struts is a load of old bollocks!
December 24, 2009 at 6:28 am
Thank you for this page, very helpfull!
July 13, 2010 at 1:27 pm
Thanks a ton! This was a great help! đŸ˜‰
August 30, 2010 at 9:42 am
thnx a lot, you made my day sir đŸ˜€