Struts-config.xml

D

dkumar

Hi,
I wanted to pass a parameter with my .do file in struts-config.xml, but
I am not successful in that. I specifically want <action
path="/submit.do?name="smith".........>. Is there a way I can use this
or is this not allowed in struts?
 
M

Manish Pandit

What you are trying to do is add request parameters externally.This is
not gonna work unless you have a query string.

I'd recommend using request scoped variables or have the URL on your
JSP carry a query string.

-cheers,
Manish
 
B

Babu Kalakrishnan

dkumar said:
Hi,
I wanted to pass a parameter with my .do file in struts-config.xml, but
I am not successful in that. I specifically want <action
path="/submit.do?name="smith".........>. Is there a way I can use this
or is this not allowed in struts?

There's a way you can fake it if your application accesses these
parameters only through the ActionForm and not directly from the
request.

Add your custom parameter as the "parameter" attribute of your action
mapping in struts-config.xml. The reset() method of the ActionForm gets
called with the ActionMapping as an argument - so you can access this
value using mapping.getParameter(), and load it to the appropriate
variable in your ActionForm.

Of course you've to be aware that since the reset() method gets called
before the form is populated, if the request does contain a parameter by
the same name, it will overwrite the value that you had stored there
from within the reset method call.

BK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
BrentonMcc
Top