This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes how can request in Struts' action get parameters from url? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how can request in Struts Watch "how can request in Struts New topic
Author

how can request in Struts' action get parameters from url?

Sean Li
Ranch Hand

Joined: Feb 27, 2002
Posts: 154
i have a link of this kind: test.do?action=create.
and in my testAction file, i wrote:
String action=request.getAttribute("action");
but later when i was using the variable action, the system tell me the action is null. why? i don't know how this comes.
so how can i get parameters from the url in Struts?
please help me, thanks!
Sean Li
Ranch Hand

Joined: Feb 27, 2002
Posts: 154
should be:
String action=(String)req.getParameter("action");
Ron Ditch
Ranch Hand

Joined: May 16, 2002
Posts: 33
Just add a string field to your view bean with the name of the URL parameter.
Struts will populate your form bean with the URL parameter.
 
GeeCON Prague 2014
 
subject: how can request in Struts' action get parameters from url?