title: Grails - URL mapping/default action and flow
body: <p>Question -</p>
  
  <p>I've noticed that some applications I test with have calls to another view/controller from an action submit, but when that page is rendered, instead of seeing:</p>
  
  <p>$controller/$page</p>
  
  <p>I see:</p>
  
  <p>$controller/index</p>
  
  <p>Is this an issue with the URL mapping configuration? Default action? Just curious, because it just appears to be the URI mapping to a default instead of the actual action.</p>
  
  <p>view code:</p>
  
  <pre><code>&lt;table&gt;
  ..
  &lt;g:actionSubmit class="stats" action="stats" value="View Stats"/&gt;
  ..
  &lt;/table
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>def stats() {
  
      def teamId = Team.get(params.id)
      def allPlayers = Player.withCriteria {
              eq('team', teamId)
              and {
                  eq('isActive', true)
              }
      }
      [allPlayers:allPlayers, teamId:params.id]
  }
  </code></pre>
  
  <p>UrlMapping:</p>
  
  <pre><code>class UrlMappings {
  
  static mappings = {
      "/$controller/$action?/$id?"{
          constraints {
              // apply constraints here
      }
  }
  }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I actually figured out what it is. Which makes me even more confused.</p>
  
  <p>The grails actionSubmit has an action tied to it. That form was just a normal form, without call:</p>
  
  <pre><code>&lt;g:form&gt;
  &lt;g:actionSubmit class="stats" action="stats" value="View Stats"/&gt;
  &lt;g:actionSubmit class="schedule" action="schedule" value="View Schedule"/&gt;
  &lt;g:form&gt;
  </code></pre>
  
  <p>So by default, the form redirects the action to $controller/index. If you add an action call in the g:form tag, those two buttons will direct to the correct page, but the URI will now be $controller/$g:form_action.</p>
  
  <p>I guess I don't get the point of the actionSubmit's action if the g:form is needed as a wrapper.</p>