Blind Squirrel

Once in a while, even a blind squirrel finds a nut.

Struts Redirect w/Parameters Part 2

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.

1
2
3
4
5
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.