You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Varlik <M....@gmx.de> on 2009/10/12 18:19:46 UTC
Proccessing parameters inside Struts action
Hi,
I'm using a Struts2 action to devliver JSON data. This action is calleb by an Ajax HTTP request. Now, I need to send some parameter along with the request. The sending of the parameters works fine but I don't know how to access them from within the struts action.
So my question is: what is the proper way to pass POST parameters to a struts action and how do I retrieve them from within the action?
Many thanks in advance.
Cheers,
Michael
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Proccessing parameters inside Struts action
Posted by Paweł Wielgus <po...@gmail.com>.
Hi Michael,
when You have in POST request myParam with myValue
then in action simply add public setter setMyParam(String value)
it's same as for standard request.
Best greetings,
Paweł Wielgus.
2009/10/12 Michael Varlik <M....@gmx.de>:
> Hi,
>
> I'm using a Struts2 action to devliver JSON data. This action is calleb by an Ajax HTTP request. Now, I need to send some parameter along with the request. The sending of the parameters works fine but I don't know how to access them from within the struts action.
> So my question is: what is the proper way to pass POST parameters to a struts action and how do I retrieve them from within the action?
>
> Many thanks in advance.
> Cheers,
> Michael
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
> ---------------------------------------------------------------------
> 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: Proccessing parameters inside Struts action
Posted by Terry Gardner <Te...@Sun.COM>.
<s:form method="post" action="MyAction">
</s:form>
In the commons classes at http://kenai.com/projects/commons, there is
a class ServletUtils with the following code to extract parameters and
place them into a Collection from a servlet request (which can be
obtained via ServletActionContext.getRequest()):
public static Collection<String> getParameters(ServletRequest
servletRequest)
{
Collection<String> results = new ArrayList<String>();
Enumeration e = servletRequest.getParameterNames();
while(e.hasMoreElements())
{
String parameterName = (String)e.nextElement();
results.add(parameterName);
}
return results;
}
On Oct 12, 2009, at 12:19 PM, Michael Varlik wrote:
> Hi,
>
> I'm using a Struts2 action to devliver JSON data. This action is
> calleb by an Ajax HTTP request. Now, I need to send some parameter
> along with the request. The sending of the parameters works fine but
> I don't know how to access them from within the struts action.
> So my question is: what is the proper way to pass POST parameters to
> a struts action and how do I retrieve them from within the action?
>
> Many thanks in advance.
> Cheers,
> Michael
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Terry.Gardner@Sun.COM
Blog: http://ff1959.wordpress.com
http://www.directory-server.org
Mobile: 404 925 6385