title: Struts2 convention and redirect parameters
body: <p>I use a Struts2 Convention plug-in to map my actions. Please, help me to solve the following problem. Here I have an action mapping</p>
  
  <pre><code>@Action(value="/{categorie:\\w+}/{hoofdgroep:\\w+}/{artikelgroep:\\w+}/", results = {
      @Result(name="success", location="articlelist.jsp"),
      @Result(name="maingroup", location="/%{categorie}/%{hoofdgroep}/", type="redirect"),
      @Result(name="category", location="/%{categorie}/", type="redirect")
  }, interceptorRefs = {
      ...
  })
  public String execute() throws Exception {
     ...
     Category category = service.getCategory(categorie);
     if (category == null) return NONE;
     ...
     MainGroup mGroup = service.getMainGroup(hoofdgroep);
     if (mGroup == null) return "category";
     ...
     ArticleGroup artGroup = service.getArticleGroup(artikelgroep);
     if (artGroup == null) return "maingroup";
     ...
     return SUCCESS;
  }
  </code></pre>
  
  <p>When, for instance, there is no artGroup for specified artikelgroep it should redirect <code>link _http://site/categorie/hoofdgroep/artikelgroep/</code> to url <code>_http://site/categorie/hoofdgroep/</code> which it perfectly does. The only problem here is that it also prepends additional parameters which are undesired. So link _<code>http://site/categorie/hoofdgroep/artikelgroep/</code> is redirected to <code>_http://site/categorie/hoofdgroep/?categorie=categorie&amp;hoofdgroep=hoofdgroep&amp;artikelgroep=artikelgroep.</code></p>
  
  <p>My question is How to get rid of these parameters?</p>
  
  <p>Here are some config params from my struts.properties file</p>
  
  <pre><code>...
  struts.serve.static=false
  struts.ognl.allowStaticMethodAccess=true
  struts.enable.DynamicMethodInvocation=false
  struts.action.extension= ,
  struts.url.includeParams=none
  
  struts.enable.SlashesInActionNames=true
  struts.mapper.alwaysSelectFullNamespace=false
  struts.patternMatcher=regex
  
  struts.convention.default.parent.package=app-default
  struts.convention.action.packages=...
  struts.convention.action.alwaysMapExecute=false
  struts.convention.package.locators.disable=true
  struts.convention.relative.result.types=dispatcher
  struts.convention.result.path=/WEB-INF/jsp/
  </code></pre>
  
  <p>So basically is this a bug or it should work this way?</p>
  
  <p>Perhaps it is not so elegant solution but here what I have done. I overrode <code>org.apache.struts2.dispatcher.ServletRedirectResult#getProhibitedResultParams</code></p>
  
  <pre><code>public class ServletRedirectResult
          extends org.apache.struts2.dispatcher.ServletRedirectResult
  {
  
      public ServletRedirectResult() {
          super();
          initProhibitedResultParams();
      }
  
      public ServletRedirectResult(String location) {
          super(location);
          initProhibitedResultParams();
      }
  
      public ServletRedirectResult(String location, String anchor) {
          super(location, anchor);
          initProhibitedResultParams();
      }
  
      private List&lt;String&gt; prohibitedParamNames;
  
      private void initProhibitedResultParams() {
  
          String[] parentParams = (String[])super.getProhibitedResultParams().toArray();
          int len = parentParams.length;
          String[] params = new String[len + 4];
          for (int i = 0; i &lt; len; i++) {
              params[i] = parentParams[i];
          }
          params[len] = "statusCode";
  
          // TODO: This is a temporary solution because RegexPatternMatcher puts parameters
          // from urls into ResultConfig for some reason.
          params[len+1] = "categorie";
          params[len+2] = "hoofdgroep";
          params[len+3] = "artikelgroep";
  
          prohibitedParamNames = Arrays.asList(params);
      }
  
      protected List&lt;String&gt; getProhibitedResultParams() {
          return prohibitedParamNames;
      }
  }
  </code></pre>