...
The request parameters are available on the ActionContext instance, which is made available via ThreadLocal.
Code Block |
---|
Map parameters = ActionContext.getContext().getParameters();
|
Implement
...
HttpParametersAware
Preferred
- Ensure that
servlet-config
Interceptor is included in the Action's stack.- The default stack already includes
servlet-config
.
- The default stack already includes
- Edit the Action so that it implements the ParameterAware HttpParametersAware interface.
- The ParameterAware HttpParametersAware interface expects a
setParameters
method. You may wish to include a companiongetParameters
method.
- The ParameterAware HttpParametersAware interface expects a
- At runtime, call
getParameters
to obtain a Map an object representing the request parameters.
Code Block |
---|
Map parameters = this.getParameters();
|
Info |
---|
When the |
Tip |
---|
To unit test a ParameterAware Action, create your own Map with the pertinent request parameters and call |
@see see struts-default.xml
@see org.apache.struts.action2.interceptor.ParameterAware
@see and org.apache.struts.action2.interceptor.Servlet Config Interceptor