You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mohit Gupta <mo...@gmail.com> on 2013/09/11 17:02:12 UTC
Redirecting to legacy action from struts 2 action ?
Hi All,
i have struts 2 action named as CustomerAction.java which is under
folderHierarchy/actions/customer(customer is namespace here). From one of
the method
inside this action class, I am redirecting to my legacy action class
ResultMapping is :-
@Result(name = "redirectTo", location = "#parameters.redirectLocation",
type = "redirect") })
where #parameters.redirectLocation is /customerhome.do?custIdId=200
Action method is :-
@Action(value = "CustomerAction!redirectToPage")
public String redirectToLocation() {
return "redirectTo";
}
But issue is struts auotomatically adding current action namespace(i.e
customer) before redirection location. So instead of
redirecting to/myWebApp/customerhome.do?custIdId=200, struts 2 is
redirecting to /myWebApp/customer/customerhome.do?custIdId=200 and i am
getting exception
HTTP Status: 404, Problem URI: /myWebApp/customer/
I am not getting why its adding cuustomer namespace and how to get rid of
this?
Re: Redirecting to legacy action from struts 2 action ?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/9/12 Mohit Gupta <mo...@gmail.com>:
> Yes i am sure value is "/customerhome.do?custIdId=200".
>
> Also do you mean that result mapping should be
> @Result(name = "redirectTo", location = " ${#parameters.redirectLocation} ",
> type = "redirect") })
>
> instead of
>
> @Result(name = "redirectTo", location = "#parameters.redirectLocation",
> type = "redirect") })
Yes
# - defines scope i.e. request, response, session, parameters, application
$, % - are expression opening chars (by default)
http://struts.apache.org/development/2.x/docs/ognl.html
And could you enabled debug for
org.apache.struts2.dispatcher.ServletRedirectResult ?
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Redirecting to legacy action from struts 2 action ?
Posted by Mohit Gupta <mo...@gmail.com>.
Yes i am sure value is "/customerhome.do?custIdId=200".
Also do you mean that result mapping should be
@Result(name = "redirectTo", location = " ${#parameters.redirectLocation} ",
type = "redirect") })
instead of
@Result(name = "redirectTo", location = "#parameters.redirectLocation",
type = "redirect") })
On Thu, Sep 12, 2013 at 4:39 PM, Lukasz Lenart <lu...@apache.org>wrote:
> 2013/9/12 Mohit Gupta <mo...@gmail.com>:
> > Lukasz, is there any workaround so that i can get rid of namespace?
> >
> > As i mentioned if i hard code the url under location attribute, it works
> > fine and does not add any namespace
> >
> > @Result(name = ComposeMessageCrudAction.REDIRECT_TO, location =
> > "/customerhome.do?custIdId=200", type = "redirect") })
> >
> >
> > But if mention any dynamic value(like getting it from
> > #parameters.redirectLocation
> > or ${redirectLocation} ), it does not work
> > @Result(name = "redirectTo", location = "#parameters.redirectLocation",
> > type = "redirect") })
>
> Are you sure that you return "/customerhome.do?custIdId=200" ("/" is
> important) from getRedirectLocation() ? And #parameters cannot work as
> ${} or %{} is the only expected opening char for an expression.
> Instead ${#parameters.redirectLocation} will work.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Redirecting to legacy action from struts 2 action ?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/9/12 Mohit Gupta <mo...@gmail.com>:
> Lukasz, is there any workaround so that i can get rid of namespace?
>
> As i mentioned if i hard code the url under location attribute, it works
> fine and does not add any namespace
>
> @Result(name = ComposeMessageCrudAction.REDIRECT_TO, location =
> "/customerhome.do?custIdId=200", type = "redirect") })
>
>
> But if mention any dynamic value(like getting it from
> #parameters.redirectLocation
> or ${redirectLocation} ), it does not work
> @Result(name = "redirectTo", location = "#parameters.redirectLocation",
> type = "redirect") })
Are you sure that you return "/customerhome.do?custIdId=200" ("/" is
important) from getRedirectLocation() ? And #parameters cannot work as
${} or %{} is the only expected opening char for an expression.
Instead ${#parameters.redirectLocation} will work.
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Redirecting to legacy action from struts 2 action ?
Posted by Mohit Gupta <mo...@gmail.com>.
Lukasz, is there any workaround so that i can get rid of namespace?
As i mentioned if i hard code the url under location attribute, it works
fine and does not add any namespace
@Result(name = ComposeMessageCrudAction.REDIRECT_TO, location =
"/customerhome.do?custIdId=200", type = "redirect") })
But if mention any dynamic value(like getting it from
#parameters.redirectLocation
or ${redirectLocation} ), it does not work
@Result(name = "redirectTo", location = "#parameters.redirectLocation",
type = "redirect") })
On Thu, Sep 12, 2013 at 12:39 PM, Lukasz Lenart <lu...@apache.org>wrote:
> 2013/9/11 Christoph Nenning <Ch...@lex-com.net>:
> > it should work when you add namespace "/" to paramters:
> >
> > @Result(
> > name = "redirectTo",
> > location = "#parameters.redirectLocation",
> > type = "redirect",
> > params={"namespace", "/"}
> > )
> >
> >
> > see this wiki page:
> > http://struts.apache.org/development/2.x/docs/redirect-result.html
>
> It's a bug in the docs ;-) Pure redirect result doesn't support
> "namespace" as it doesn't make sense when you performing redirect to
> some web resource (not an action). Docs updated:
>
> https://cwiki.apache.org/confluence/display/WW/Redirect+Result
>
> @Result(name = "redirectTo", location = "${redirectLocation}", type =
> "redirect") })
>
> and the redirectLocation will be resolved against the current action
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Redirecting to legacy action from struts 2 action ?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/9/11 Christoph Nenning <Ch...@lex-com.net>:
> it should work when you add namespace "/" to paramters:
>
> @Result(
> name = "redirectTo",
> location = "#parameters.redirectLocation",
> type = "redirect",
> params={"namespace", "/"}
> )
>
>
> see this wiki page:
> http://struts.apache.org/development/2.x/docs/redirect-result.html
It's a bug in the docs ;-) Pure redirect result doesn't support
"namespace" as it doesn't make sense when you performing redirect to
some web resource (not an action). Docs updated:
https://cwiki.apache.org/confluence/display/WW/Redirect+Result
@Result(name = "redirectTo", location = "${redirectLocation}", type =
"redirect") })
and the redirectLocation will be resolved against the current action
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Redirecting to legacy action from struts 2 action ?
Posted by Mohit Gupta <mo...@gmail.com>.
Folks,
Any help would be appreciated.
On Wed, Sep 11, 2013 at 9:43 PM, Mohit Gupta <mo...@gmail.com> wrote:
> Another observation is
>
> what works
> @Result(name = ComposeMessageCrudAction.REDIRECT_TO, location =
> "/customerhome.do?custIdId=200", type = "redirect") })
>
>
> what does not work
> @Result(name = "redirectTo", location = "#parameters.redirectLocation",
> type = "redirect") })
>
> where value of #parameters.redirectLocation is
> /customerhome.do?custIdId=200
>
> *i am not getting why second approach is not working and why its adding
> customer namespace before *
> */customerhome.do?custIdId=200*
>
>
> On Wed, Sep 11, 2013 at 8:54 PM, Mohit Gupta <mo...@gmail.com> wrote:
>
>> params={"namespace", "/"} did not help. Still it adds the customer
>> namespace
>>
>>
>> On Wed, Sep 11, 2013 at 8:40 PM, Christoph Nenning <
>> Christoph.Nenning@lex-com.net> wrote:
>>
>>> it should work when you add namespace "/" to paramters:
>>>
>>> @Result(
>>> name = "redirectTo",
>>> location = "#parameters.redirectLocation",
>>> type = "redirect",
>>> params={"namespace", "/"}
>>> )
>>>
>>>
>>> see this wiki page:
>>> http://struts.apache.org/development/2.x/docs/redirect-result.html
>>>
>>>
>>> Regards,
>>> Christoph
>>>
>>>
>>>
>>> >
>>> > Hi All,
>>> >
>>> > i have struts 2 action named as CustomerAction.java which is under
>>> > folderHierarchy/actions/customer(customer is namespace here). From one
>>> of
>>> > the method
>>> > inside this action class, I am redirecting to my legacy action class
>>> >
>>> > ResultMapping is :-
>>> > @Result(name = "redirectTo", location = "#parameters.redirectLocation",
>>> > type = "redirect") })
>>> >
>>> > where #parameters.redirectLocation is /customerhome.do?custIdId=200
>>> >
>>> > Action method is :-
>>> > @Action(value = "CustomerAction!redirectToPage")
>>> > public String redirectToLocation() {
>>> > return "redirectTo";
>>> > }
>>> >
>>> > But issue is struts auotomatically adding current action namespace(i.e
>>> > customer) before redirection location. So instead of
>>> > redirecting to/myWebApp/customerhome.do?custIdId=200, struts 2 is
>>> > redirecting to /myWebApp/customer/customerhome.do?custIdId=200 and i am
>>> > getting exception
>>> > HTTP Status: 404, Problem URI: /myWebApp/customer/
>>> >
>>> >
>>> > I am not getting why its adding cuustomer namespace and how to get rid
>>> of
>>> > this?
>>>
>>> This Email was scanned by Sophos Anti Virus
>>>
>>
>>
>
Re: Redirecting to legacy action from struts 2 action ?
Posted by Mohit Gupta <mo...@gmail.com>.
Another observation is
what works
@Result(name = ComposeMessageCrudAction.REDIRECT_TO, location =
"/customerhome.do?custIdId=200", type = "redirect") })
what does not work
@Result(name = "redirectTo", location = "#parameters.redirectLocation",
type = "redirect") })
where value of #parameters.redirectLocation is
/customerhome.do?custIdId=200
*i am not getting why second approach is not working and why its adding
customer namespace before *
*/customerhome.do?custIdId=200*
On Wed, Sep 11, 2013 at 8:54 PM, Mohit Gupta <mo...@gmail.com> wrote:
> params={"namespace", "/"} did not help. Still it adds the customer
> namespace
>
>
> On Wed, Sep 11, 2013 at 8:40 PM, Christoph Nenning <
> Christoph.Nenning@lex-com.net> wrote:
>
>> it should work when you add namespace "/" to paramters:
>>
>> @Result(
>> name = "redirectTo",
>> location = "#parameters.redirectLocation",
>> type = "redirect",
>> params={"namespace", "/"}
>> )
>>
>>
>> see this wiki page:
>> http://struts.apache.org/development/2.x/docs/redirect-result.html
>>
>>
>> Regards,
>> Christoph
>>
>>
>>
>> >
>> > Hi All,
>> >
>> > i have struts 2 action named as CustomerAction.java which is under
>> > folderHierarchy/actions/customer(customer is namespace here). From one
>> of
>> > the method
>> > inside this action class, I am redirecting to my legacy action class
>> >
>> > ResultMapping is :-
>> > @Result(name = "redirectTo", location = "#parameters.redirectLocation",
>> > type = "redirect") })
>> >
>> > where #parameters.redirectLocation is /customerhome.do?custIdId=200
>> >
>> > Action method is :-
>> > @Action(value = "CustomerAction!redirectToPage")
>> > public String redirectToLocation() {
>> > return "redirectTo";
>> > }
>> >
>> > But issue is struts auotomatically adding current action namespace(i.e
>> > customer) before redirection location. So instead of
>> > redirecting to/myWebApp/customerhome.do?custIdId=200, struts 2 is
>> > redirecting to /myWebApp/customer/customerhome.do?custIdId=200 and i am
>> > getting exception
>> > HTTP Status: 404, Problem URI: /myWebApp/customer/
>> >
>> >
>> > I am not getting why its adding cuustomer namespace and how to get rid
>> of
>> > this?
>>
>> This Email was scanned by Sophos Anti Virus
>>
>
>
Re: Redirecting to legacy action from struts 2 action ?
Posted by Mohit Gupta <mo...@gmail.com>.
params={"namespace", "/"} did not help. Still it adds the customer
namespace
On Wed, Sep 11, 2013 at 8:40 PM, Christoph Nenning <
Christoph.Nenning@lex-com.net> wrote:
> it should work when you add namespace "/" to paramters:
>
> @Result(
> name = "redirectTo",
> location = "#parameters.redirectLocation",
> type = "redirect",
> params={"namespace", "/"}
> )
>
>
> see this wiki page:
> http://struts.apache.org/development/2.x/docs/redirect-result.html
>
>
> Regards,
> Christoph
>
>
>
> >
> > Hi All,
> >
> > i have struts 2 action named as CustomerAction.java which is under
> > folderHierarchy/actions/customer(customer is namespace here). From one
> of
> > the method
> > inside this action class, I am redirecting to my legacy action class
> >
> > ResultMapping is :-
> > @Result(name = "redirectTo", location = "#parameters.redirectLocation",
> > type = "redirect") })
> >
> > where #parameters.redirectLocation is /customerhome.do?custIdId=200
> >
> > Action method is :-
> > @Action(value = "CustomerAction!redirectToPage")
> > public String redirectToLocation() {
> > return "redirectTo";
> > }
> >
> > But issue is struts auotomatically adding current action namespace(i.e
> > customer) before redirection location. So instead of
> > redirecting to/myWebApp/customerhome.do?custIdId=200, struts 2 is
> > redirecting to /myWebApp/customer/customerhome.do?custIdId=200 and i am
> > getting exception
> > HTTP Status: 404, Problem URI: /myWebApp/customer/
> >
> >
> > I am not getting why its adding cuustomer namespace and how to get rid
> of
> > this?
>
> This Email was scanned by Sophos Anti Virus
>
Antwort: Redirecting to legacy action from struts 2 action ?
Posted by Christoph Nenning <Ch...@lex-com.net>.
it should work when you add namespace "/" to paramters:
@Result(
name = "redirectTo",
location = "#parameters.redirectLocation",
type = "redirect",
params={"namespace", "/"}
)
see this wiki page:
http://struts.apache.org/development/2.x/docs/redirect-result.html
Regards,
Christoph
>
> Hi All,
>
> i have struts 2 action named as CustomerAction.java which is under
> folderHierarchy/actions/customer(customer is namespace here). From one
of
> the method
> inside this action class, I am redirecting to my legacy action class
>
> ResultMapping is :-
> @Result(name = "redirectTo", location = "#parameters.redirectLocation",
> type = "redirect") })
>
> where #parameters.redirectLocation is /customerhome.do?custIdId=200
>
> Action method is :-
> @Action(value = "CustomerAction!redirectToPage")
> public String redirectToLocation() {
> return "redirectTo";
> }
>
> But issue is struts auotomatically adding current action namespace(i.e
> customer) before redirection location. So instead of
> redirecting to/myWebApp/customerhome.do?custIdId=200, struts 2 is
> redirecting to /myWebApp/customer/customerhome.do?custIdId=200 and i am
> getting exception
> HTTP Status: 404, Problem URI: /myWebApp/customer/
>
>
> I am not getting why its adding cuustomer namespace and how to get rid
of
> this?
This Email was scanned by Sophos Anti Virus