title: Struts2 Action Regular Expression/Wild card for URL
body: <p>I am new to Struts2 but so far I have made decent progress using the API. However, I am stuck at something which I need to get out from. I am using Struts2 with Spring integration. I am writing my Action classes with annotation as like many of you I love annotations.</p>
  
  <p>My requirement is that URLs will be in the following nature:</p>
  
  <pre><code>http://&lt;DOMAIN&gt;/program/program1.jspx
  http://&lt;DOMAIN&gt;/program/program2.jspx
  http://&lt;DOMAIN&gt;/program/program3.jspx
  </code></pre>
  
  <p>As you can see there is a certain pattern in the URL with program1, program2 and program3 varying and the rest are all static. I have very easily handled similar situation with Spring MVC (I don't have the option of using Spring MVC for the current project) like <code>"/program/{program_name}.jspx"</code> in my other project.</p>
  
  <p>But when I use the same in struts2 I get the error. My Action class is as follows:</p>
  
  <pre><code>@Result(name="program", location="program", type="tiles")
  public class ProgramAction extends ActionSupport {
  
     @Action("program/{programName}")
     public String getProgramPage() {
       // few more lines of code  
       return "program";      
    }
  }
  </code></pre>
  
  <p>The error is </p>
  
  <pre><code>2013-02-28 15:46:35.591 WARN  [http-bio-8080-exec-3] CommonsLogger.java:60 
  Could not find action or result
  com.opensymphony.xwork2.config.ConfigurationException: There is no Action mapped for namespace / and action name program1.
  at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189) ~[xwork-core-2.2.1.jar:2.2.1]
  at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) ~[struts2-core-2.2.1.jar:2.2.1]
  at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) ~[struts2-core-2.2.1.jar:2.2.1]
  at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) ~[xwork-core-2.2.1.jar:2.2.1]
  at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) ~[struts2-core-2.2.1.jar:2.2.1]
  ....
  ....
  </code></pre>
  
  <p>My <code>struts.xml</code> file is as follows:</p>
  
  <pre><code>&lt;struts&gt;
  &lt;constant name="struts.convention.default.parent.package" value="default"/&gt;
  &lt;constant name="struts.action.extension" value="jspx" /&gt;
  &lt;constant name="struts.mapper.alwaysSelectFullNamespace" value="false" /&gt;
  &lt;constant name="struts.enable.DynamicMethodInvocation" value="true" /&gt;
  
  &lt;package name="default" extends="struts-default, json-default, rest-default" namespace="/"&gt;       
      &lt;result-types&gt;
          &lt;result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/&gt;
          &lt;result-type name="json" class="org.apache.struts2.json.JSONResult"/&gt;
      &lt;/result-types&gt;
  &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>