title: REST get user by id and nickname
body: <p>What is the best way to create @RequestMapping when i need to find user by id (e.g. "api.com/id5") and by nickname ("api.com/nick1")? I have problem with same pattern and Spring mapping can define "id1" as a nickname (but it is impossible because the nicknames are checked before registration). I thought that the code has to be like this:
  </p>
  
  <pre><code>@RequestMapping(value = "/id{id}", method = RequestMethod.GET)
      public ResponseEntity&lt;Object&gt; getUserById(@PathParam("id") long id){
          return ...;
      }
  
      @RequestMapping(value = "/{nickname}", method = RequestMethod.GET)
      public ResponseEntity getUserByNickname(@PathParam("nickname") String nickname){
          return ...;
      }
  </code></pre>
  
  <p>One more solution: get just a string from uri path and manually check, is it an id or nickname.
  So, how to do it the right way?</p>