You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Xibin Liu <Xi...@pwgsc.gc.ca> on 2007/09/24 17:02:28 UTC
[Struts 2] Read request attribute in struts.xml
Hi, I set an attribute in the request in the action code, and I want to
use it in the struts.xml (see below). How can I reference it at the
place marked by ***?
<action name="actionname" class="classname">
<result type="redirect">
<param name="location">***</param>
<param name="parse">true</param>
</result>
</action>
I tried #request.attname, it did not work.
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Struts 2] Read request attribute in struts.xml
Posted by Jim Cushing <ji...@mac.com>.
Mark Menard's excellent Struts 2 Cookbook shows you how to do this.
http://www.vitarara.org/cms/struts_2_cookbook/post_and_redirect
If you've never seen his Cookbook, I definitely recommend taking a
look. It's got some great tips.
On Sep 24, 2007, at 11:02 AM, Xibin Liu wrote:
>
> Hi, I set an attribute in the request in the action code, and I
> want to
> use it in the struts.xml (see below). How can I reference it at the
> place marked by ***?
>
>
> <action name="actionname" class="classname">
> <result type="redirect">
> <param name="location">***</param>
> <param name="parse">true</param>
> </result>
> </action>
>
>
> I tried #request.attname, it did not work.
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: [Struts 2] Read request attribute in struts.xml
Posted by Xibin Liu <Xi...@pwgsc.gc.ca>.
I created a property for the attribute, then reference it by $propName,
and it works. Thanks Dave!
Also thanks Jim for pointing me to the struts 2 cookbook. That is a
great resource!
-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com]
Sent: Monday, September 24, 2007 11:08 AM
To: Struts Users Mailing List
Subject: Re: [Struts 2] Read request attribute in struts.xml
Xibin Liu wrote:
> Hi, I set an attribute in the request in the action code, and I want
> to use it in the struts.xml (see below). How can I reference it at the
> place marked
by
> ***?
>
>
> <action name="actionname" class="classname">
> <result type="redirect">
> <param name="location">***</param>
> <param name="parse">true</param>
> </result>
> </action>
(Ugh, mixed tabs and spaces :p Tabs are bad enough! ;)
> I tried #request.attname, it did not work.
Did you try $request.attname or $parameters.attname?
The EL here is OGNL, but confusingly uses a "$"
instead of an "%".
Is there a particular reason you're putting it in the request instead of
making it an Action property? If it's a property referencing it with
$propName is known to work.
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Struts 2] Read request attribute in struts.xml
Posted by Dave Newton <ne...@yahoo.com>.
Xibin Liu wrote:
> Hi, I set an attribute in the request in the action
> code, and I want to use it in the struts.xml (see
> below). How can I reference it at the place marked
by
> ***?
>
>
> <action name="actionname" class="classname">
> <result type="redirect">
> <param name="location">***</param>
> <param name="parse">true</param>
> </result>
> </action>
(Ugh, mixed tabs and spaces :p Tabs are bad enough! ;)
> I tried #request.attname, it did not work.
Did you try $request.attname or $parameters.attname?
The EL here is OGNL, but confusingly uses a "$"
instead of an "%".
Is there a particular reason you're putting it in the
request instead of making it an Action property? If
it's a property referencing it with $propName is known
to work.
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org