struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: [S2] Action attribute of submit
Date Mon, 04 Feb 2008 06:22:47 GMT
hezjing wrote:
> Hi
>
> In http://struts.apache.org/2.0.11/docs/submit.html, the submit tag
> has an "action" attribute that says "set action attribute."
>
> May I know how can we make use of this action attribute?
> Any example?
>
> Thank  you!
>
>
>   
It simply overrides the action attribute of the form:

<s:submit name="submit" value="a" action="action1"/>
<s:submit name="submit" value="a" action="action2"/>

where action1 and action2 are actions named in struts.xml

The way it works is that the value of the button has the name of the 
action added to it.  The ActionMap in struts2 inspects the params, 
detects the "action:" prefix and executes the named action instead of 
the one in the URL.  The prefix is then stripped off the value.

The method attribute works the same way (adds a method: prefix)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message