You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tony Lin <li...@gmail.com> on 2008/01/01 10:51:17 UTC

some question about adding parameter when redirecting in struts.

hi all,
    Happy new year!
    I have got a question about how to set parameter to the url when using
redirect in struts.
    For example, i am going to update a persion's profile. And I am using
PersonUpdateAction to do this. When I finish doing the update operation I
would redirect to the page which show the profile, the view mode not edit
mode. Here is the sequence.

view  profile  --->  personview.do?name=tony  ----(go to edit mode)---->
> personedit.do?name=tony  ---(update the profile and return to view
> mode)--->  personview.do?name=tony
>

   Now the problem comes up. In PersonUpdateAction I finish the update
operation, and go to redirect to personview.do. But the URL in the Browser
is personedit.do, not personview.do?name=tony. I want to and the parameter
like "?name=tony" to the url.

<action path="/personupdate" type="PersonUpdateAction"
>     scope="request">
>     <forward name="info" redirect="false"
>         path="/personview.do" />
> </action>
>


   Do you know what I am talking about?

 regards tony lin

Re: some question about adding parameter when redirecting in struts.

Posted by Paul Benedict <pb...@apache.org>.
Use ActionRedirect class. Grab the forward from mapping.findForward, wrap,
and add parameters.

Paul

On Jan 1, 2008 3:51 AM, Tony Lin <li...@gmail.com> wrote:

> hi all,
>    Happy new year!
>    I have got a question about how to set parameter to the url when using
> redirect in struts.
>    For example, i am going to update a persion's profile. And I am using
> PersonUpdateAction to do this. When I finish doing the update operation I
> would redirect to the page which show the profile, the view mode not edit
> mode. Here is the sequence.
>
> view  profile  --->  personview.do?name=tony  ----(go to edit mode)---->
> > personedit.do?name=tony  ---(update the profile and return to view
> > mode)--->  personview.do?name=tony
> >
>
>   Now the problem comes up. In PersonUpdateAction I finish the update
> operation, and go to redirect to personview.do. But the URL in the Browser
> is personedit.do, not personview.do?name=tony. I want to and the parameter
> like "?name=tony" to the url.
>
> <action path="/personupdate" type="PersonUpdateAction"
> >     scope="request">
> >     <forward name="info" redirect="false"
> >         path="/personview.do" />
> > </action>
> >
>
>
>   Do you know what I am talking about?
>
>  regards tony lin
>