title: XML response from API with PathVariable
body: <p>I have the API:</p>
  
  <pre><code>@GetMapping(path = "/users/{userId}")
  public ResponseEntity&lt;UserDTO&gt; getUserById(@PathVariable(value = "userId") Long userId) {
      //logic here
  }
  </code></pre>
  
  <p>it returns JSON response, as it should.</p>
  
  <p>And there's another app that I don't have access to, and it calls my API as, for example, <code>GET /users/123.xml</code> in order to receive XML response.</p>
  
  <p>But in this case, my API fails with <code>400</code> error, because it cannot parse <code>123.xml</code> into <code>Long</code>.</p>
  
  <p>Option <code>@GetMapping(value = {"/users/{userId}", "/users/{userId}.xml"})</code> fails with the same error.</p>
  
  <p>What can I do to respond with XML syntax when calling <code>/{userId}.xml</code> and in the mean time, respond with JSON syntax when calling <code>/{userId}</code>?</p>
  
  <p>EDIT: </p>
  
  <p>I want it to do without specifically adding 'Accept' headers, and without writing any additional logic, that'll parse <code>{userId}.xml</code> and then set the appropriate response type.</p>