You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Thompson <el...@gmail.com> on 2007/02/06 01:53:53 UTC
Struts 2 Action Mapping - Redirect
Hey all,
I'm using Struts 2 (version 2.0.2) in a simple web application running on
Tomcat. I have a page to submit data, and after the "saveData" method in my
action class is called, I'd like to have it redirect to the editData page
for the newly-entered data.
I've tried putting the following in my struts.xml:
<action name="saveNewType" class="my.package.TypeManagement"
method="saveNew">
<interceptor-ref name="adminCheck"/>
<result name="success" type="redirect">editType.action
?id=${id}</result>
</action>
According to the documentation, this should work, but instead, I get
redirected to
http://my.server.com/myproj/editType.action?id=${id}
Has anyone run into anything similar?
Thanks,
Brian Thompson
Re: Struts 2 Action Mapping - Redirect
Posted by Brian Thompson <el...@gmail.com>.
The URL that my action mapping below produced is:
http://localhost:8080/OLT/mgt/manageCourseTypes!password.action?id=f6a08f77-1680-4945-b979-8a833c28b88d
instead of
http://localhost:8080/OLT/mgt/manageCourseTypes.action?id=f6a08f77-1680-4945-b979-8a833c28b88d
-Brian
On 2/6/07, Brian Thompson <el...@gmail.com> wrote:
>
> I also tried switching to the nested-elements syntax for my action:
>
> <action name="saveNewType" class="my.package.TypeManagement"
> method="saveNew">
> <interceptor-ref name="adminCheck"/>
> <result name="success" type="redirect-action">
> <param name="actionName">manageCourseTypes</param>
> <param name="namespace">/mgt</param>
> <param name="id">${id}</param>
> </result>
> </action>
>
> Which produced:
>
> [OLT] WARN [http-8080-Processor25] OgnlUtil.internalSetProperty(369) |
> Caught OgnlException while setting property 'id' on type '
> org.apache.struts2.dispatcher.ServletActionRedirectResult '.
>
> and a stack trace for
>
> ognl.NoSuchPropertyException:
> org.apache.struts2.dispatcher.ServletActionRedirectResult.id
>
>
> -Brian
>
>
> On 2/5/07, Nate Drake <nd...@gmail.com> wrote:
> >
> > Try using the "redirect-action" result type.
> >
> > http://struts.apache.org/2.x/docs/redirect-action-result.html
> >
>
>
>
>
Re: Struts 2 Action Mapping - Redirect
Posted by Brian Thompson <el...@gmail.com>.
I also tried switching to the nested-elements syntax for my action:
<action name="saveNewType" class="my.package.TypeManagement"
method="saveNew">
<interceptor-ref name="adminCheck"/>
<result name="success" type="redirect-action">
<param name="actionName">manageCourseTypes</param>
<param name="namespace">/mgt</param>
<param name="id">${id}</param>
</result>
</action>
Which produced:
[OLT] WARN [http-8080-Processor25] OgnlUtil.internalSetProperty(369) |
Caught OgnlException while setting property 'id' on type '
org.apache.struts2.dispatcher.ServletActionRedirectResult'.
and a stack trace for
ognl.NoSuchPropertyException:
org.apache.struts2.dispatcher.ServletActionRedirectResult.id
-Brian
On 2/5/07, Nate Drake <nd...@gmail.com> wrote:
>
> Try using the "redirect-action" result type.
>
> http://struts.apache.org/2.x/docs/redirect-action-result.html
>
Re: Struts 2 Action Mapping - Redirect
Posted by Nate Drake <nd...@gmail.com>.
The NPE in ServletRedirectResult is a bug. It has been fixed in 2.0.5
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2 Action Mapping - Redirect
Posted by Brian Thompson <el...@gmail.com>.
Thanks for the idea! Sadly, that just makes it worse. When I switch to
type="redirect-action", I don't even get forwarded to the next action. I
get
Struts Problem Report
Struts has detected an unhandled exception:
*Messages*:
*File*: org/apache/struts2/dispatcher/ServletRedirectResult.java *Line
number*: 126
and a NullPointerException stack trace.
Has anyone run into either of these problems before?
-Brian
On 2/5/07, Nate Drake <nd...@gmail.com> wrote:
>
> Try using the "redirect-action" result type.
>
> http://struts.apache.org/2.x/docs/redirect-action-result.html
>
Re: Struts 2 Action Mapping - Redirect
Posted by Nate Drake <nd...@gmail.com>.
Try using the "redirect-action" result type.
http://struts.apache.org/2.x/docs/redirect-action-result.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org