You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

You can obtain the request parameters by asking the ActionContext or implementing ParameterAware. Implementing ParameterAware is preferred.

Ask the ActionContext

The request parameters are available on the ActionContext instance, which is made available via ThreadLocal.

Map parameters = ActionContext.getContext().getParameters();

Implement ParameterAware

(star) Preferred

  • Ensure that servlet-config Interceptor is included in the Action's stack.
    • (info) The default stack already includes servlet-config.
  • Edit the Action so that it implements the ParameterAware interface.
    • The ParameterAware interface expects a setParameters method. You may wish to include a companion getParameters method.
  • At runtime, call getParameters to obtain a Map representing the request parameters.
Map parameters = this.getParameters();

When the servlet-config Interceptor sees that an Action implements ParameterAware, it passes a Map of the request parameters to the Action's setParameters method.

@see action-default.xml
@see com.opensymphony.webwork.interceptor.ParameterAware
@see com.opensymphony.webwork.interceptor.Servlet Config Interceptor

  • No labels