title: How to exclude url mappings from @RequestMapping in Spring?
body: <p>I've a request mapping that handles any string after the context e.g. <strong>www.example.com/anystring</strong></p>
  
  <p>I'm handling it as follows:</p>
  
  <pre><code>@RequestMapping(value="/{str}", method = RequestMethod.GET)
  public String getApp(@PathVariable("str") String anyString, ModelMap model) {
          //Do something
      }
  </code></pre>
  
  <p>The problem is I've 2-3 URLs in my app where the URL is as follows: <strong>www.example.com/about</strong>, <strong>www.example.com/contact</strong> etc.</p>
  
  <p>I wrote Request Mappings for them as follows:</p>
  
  <pre><code>@RequestMapping("/about")
      public String getAboutPage() {
          return "about";
      }
  </code></pre>
  
  <p>But obviously, since I've already declared that any string should be handled by the <code>getApp()</code>, the <code>getAboutPage()</code> never gets executed.
  How can I exclude <code>/about</code>, <code>/contact</code> etc from <code>getApp()</code> mapping.
  We can obviously add another keyword to the URL string, but that's not possible in my app use case. 
  Kindly help. :(</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Should I just handle <code>/about</code>, <code>/contact</code> inside <code>getApp()</code> like:</p>
  
  <pre><code>@RequestMapping(value="/{str}", method = RequestMethod.GET)
      public String getApp(@PathVariable("str") String anyString, ModelMap model) {
  
      if(anyString.equals("about")){
       //do about related stuff
      }
  
      if(anyString.equals("contact")){
       //do contact related stuff
      }
  
      //Do something
      }
  </code></pre>
  
  <p>Is there a better way?</p>