title: Getting Interceptor Parameters in Struts 2
body: <p>I have following action mapping</p>
  
  <pre><code>&lt;action name="theAction" ...&gt;
  ...
      &lt;param name="param1"&gt;one&lt;/param&gt;
      &lt;param name="param2"&gt;two&lt;/param&gt;
      ...
      &lt;param name="paramN"&gt;nth-number&lt;/param&gt;
  ...
  &lt;/action&gt;
  </code></pre>
  
  <p>I can get parameter map using following line in Interceptor</p>
  
  <pre><code>Map&lt;String, Object&gt; params = ActionContext.getContext().getParameters();
  </code></pre>
  
  <p>Just as above, <strong>is there any way to get interceptor parameters</strong> as defined in following mapping.</p>
  
  <pre><code>&lt;action name="theAction" ...&gt;
  ...
      &lt;interceptor-ref name="theInterceptor"&gt;
          &lt;param name="param1"&gt;one&lt;/param&gt;
          &lt;param name="param2"&gt;two&lt;/param&gt;
          ...
          &lt;param name="paramN"&gt;nth-number&lt;/param&gt;
      &lt;/interceptor-ref&gt;
  ...
  &lt;/action&gt;
  </code></pre>
  
  <p>And action parameters are defined in following way, action parameters and interceptor parameters should be accessible separately.</p>
  
  <pre><code>&lt;action name="theAction" ...&gt;
  ...
      &lt;param name="param1"&gt;one&lt;/param&gt;
      &lt;param name="param2"&gt;two&lt;/param&gt;
      ...
      &lt;param name="paramN"&gt;nth-number&lt;/param&gt;
      ....
      &lt;interceptor-ref name="theInterceptor"&gt;
          &lt;param name="param1"&gt;one&lt;/param&gt;
          &lt;param name="param2"&gt;two&lt;/param&gt;
          ...
          &lt;param name="paramN"&gt;nth-number&lt;/param&gt;
      &lt;/interceptor-ref&gt;
  ...
  &lt;/action&gt;
  </code></pre>
  
  <p>Please note that I don't want to declare parameter fields in my interceptor as</p>
  
  <pre><code>//all fields with their getters and setters
  private String param1;
  private String param2;
  ...
  private String paramN;
  </code></pre>
  
  <hr>
  
  <p>After Dev Blanked's asnwer, I implemented his technique. It did not work so I am sharing my code here. I am using Struts 2.3.1.2.</p>
  
  <p><strong>Libraries</strong></p>
  
  <ul>
  <li>asm-3.3.jar</li>
  <li>asm-commons-3.3.jar</li>
  <li>asm-tree-3.3.jar</li>
  <li>commons-fileupload-1.2.2.jar</li>
  <li>commons-io-2.0.1.jar</li>
  <li>commons-lang-2.5.jar</li>
  <li>freemarker-2.3.18.jar</li>
  <li>javassist-3.11.0.GA.jar</li>
  <li>ognl-3.0.4.jar</li>
  <li>struts2-core-2.3.1.2.jar</li>
  <li>xwork-core-2.3.1.2.jar</li>
  </ul>
  
  <p><strong>Struts.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;!DOCTYPE struts PUBLIC
      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
      "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
      &lt;constant name="struts.devMode" value="true" /&gt;
  
      &lt;package name="the-base" namespace="/" extends="struts-default" abstract="true"&gt;
  
          &lt;interceptors&gt;
              &lt;interceptor name="header" class="demo.interceptors.HttpHeaderInterceptor"&gt;&lt;/interceptor&gt;
  
          &lt;interceptor-stack name="theStack"&gt;
              &lt;interceptor-ref name="defaultStack"&gt;&lt;/interceptor-ref&gt;
                  &lt;interceptor-ref name="header"&gt;&lt;/interceptor-ref&gt;
              &lt;/interceptor-stack&gt;
          &lt;/interceptors&gt;
  
          &lt;default-interceptor-ref name="theStack"&gt;&lt;/default-interceptor-ref&gt;
  
      &lt;/package&gt;
  
      &lt;package name="the-module" extends="the-base"&gt;
          &lt;action name="theAction"&gt;
              &lt;result&gt;/the-action.jsp&lt;/result&gt;
              &lt;interceptor-ref name="theStack"&gt;
                  &lt;param name="header.Cache-control"&gt;no-store,no-cache&lt;/param&gt;
                  &lt;param name="header.Pragma"&gt;no-cache&lt;/param&gt;
                  &lt;param name="header.Expires"&gt;-1&lt;/param&gt;
                  &lt;param name="header.arbitrary"&gt;true&lt;/param&gt;
              &lt;/interceptor-ref&gt;
          &lt;/action&gt;
      &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  
  <p><strong>Interceptor</strong></p>
  
  <pre><code>package demo.interceptors;
  
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Map.Entry;
  
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts2.StrutsStatics;
  
  import com.opensymphony.xwork2.ActionInvocation;
  import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
  
  public class HttpHeaderInterceptor extends AbstractInterceptor {
  
      private final Map&lt;String, String&gt; interceptorConfigs = new HashMap&lt;String, String&gt;();
  
      @Override
      public String intercept(ActionInvocation invocation) throws Exception {
          System.out.println("Calling 'intercept' method.");
          HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get(StrutsStatics.HTTP_RESPONSE);
  
          for(Entry&lt;String, String&gt; entry: interceptorConfigs.entrySet()) {
              String header = entry.getKey();
              String value = entry.getValue();
              System.out.printf("Adding header: %s=%s\n",header,value);
              response.setHeader(header, value);
          }
  
          return invocation.invoke();
      }
  
      public Map&lt;String, String&gt; getInterceptorConfigs() {
          System.out.println("calling method 'getInterceptorConfigs'");
          return interceptorConfigs;
      }
  
      public void addInterceptorConfig(final String configName, final String configValue) {
          System.out.printf("Calling method 'addInterceptorConfig' with params configName = %s, configValue=%.\n",configName, configValue);
          interceptorConfigs.put(configName, configValue);
      }
  
  }
  </code></pre>
  
  <p><strong>Console Output</strong> when <code>theAction</code> is hit.</p>
  
  <pre><code>Calling 'intercept' method. 
  </code></pre>