title: Some information about @MatrixVariable annotation ins Spring 3.2
body: <p>today I am studying the Spring MVC showcase dowlodable from the STS dashboard</p>
  
  <p>I have some doubt about the new annotation <strong>@MatrixVariable</strong> introduced by Spring 3.2 version and the use of the Matrix variables in the URI path.</p>
  
  <p>Within my home.jsp view I have the following link:</p>
  
  <pre><code>&lt;a id="matrixVar" class="textLink" href="&lt;c:url value="/data/matrixvars;foo=bar/simple" /&gt;"&gt;Matrix variable&lt;/a&gt;
  </code></pre>
  
  <p>Reading here the official documentation about <strong>@MatrixVariable</strong> annotation: <a href="http://static.springsource.org/spring-framework/docs/3.2.0.M2/reference/html/mvc.html#mvc-ann-matrix-variables">http://static.springsource.org/spring-framework/docs/3.2.0.M2/reference/html/mvc.html#mvc-ann-matrix-variables</a></p>
  
  <p>I have understand the following thing:</p>
  
  <p>1) Matrix variables are a couple 
  2) I can put these variable in any URI path segment</p>
  
  <p>So I have some doubts about the previous link: </p>
  
  <ol>
  <li><p><strong>What is the URI called when I click on the previus link?</strong></p>
  
  <p>Is it /spring-mvc-showcase/data/matrixvars/simple ?!?! (with spring-mvc-showcase that is only the application name)</p></li>
  <li><p><strong>It would have been indifferent if I had put the "foo" matrix variable in some other position?</strong></p></li>
  </ol>
  
  <p>For example if I put the "foo" variabile in this way:</p>
  
  <p>"/data;foo=bar/matrixvars/simple" </p>
  
  <p>or in this way:</p>
  
  <p>"/data/matrixvars/simple;foo=bar"</p>
  
  <p>Has it the same meaning? </p>
  
  <p>Ok, now this is the controller method that handles the HTTP Request generated by clicking the link:</p>
  
  <pre><code>@RequestMapping(value="{path}/simple", method=RequestMethod.GET)
  public @ResponseBody String withMatrixVariable(@PathVariable String path, @MatrixVariable String foo) {
      return "Obtained matrix variable 'foo=" + foo + "' from path segment '" + path + "'";
  }
  </code></pre>
  
  <p>This method use the URI Template pattern to accede to a specific position of the URI.</p>
  
  <p>So if my URI is <strong>data/matrixvars/simple</strong> and because my entire class is annoted by <strong>@RequestMapping("/data")</strong> annotation and my controller method is annoted by: <strong>@RequestMapping(value="{path}/simple", method=RequestMethod.GET)</strong> that means the following thing?</p>
  
  <p>the path URI Template variable is related to the second URI position (that in the current URI is matrixvars) and so this method can handle also URI like:</p>
  
  <pre><code>/spring-mvc-showcase/data/SOMETHING/simple 
  </code></pre>
  
  <p>Is it right?</p>
  
  <p>Thank you very much</p>
  
  <p>Andrea</p>