title: Handling special characters in REST API
body: <p>I am having following URL</p>
  
  <pre><code>http://context_path/info/abc/def
  </code></pre>
  
  <p>which gets converted like</p>
  
  <pre><code>http://context_path/info/abc%2Fdef
  </code></pre>
  
  <p>Where as my controller mapping is:</p>
  
  <pre><code>@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
  </code></pre>
  
  <p>here <em>'id'</em> contains forward slash (/). So when I hit the URL I get <strong>400 Bad Request</strong>. </p>
  
  <p>I know the <em>possible solutions</em> </p>
  
  <ul>
  <li>Setting tomcat to allow forward slash.</li>
  <li>Use URL encoding.</li>
  <li>Use of <code>@RequestParam</code> instead of <code>@PathVariable</code>.</li>
  </ul>
  
  <p>But above solution are not possible for me.</p>
  
  <p><strong>Q.</strong> Is there any other solution like (using regular expression or changing the mapping or anything else) to the problem ?
  Also how the tomcat treats other special characters <strong>('.' , ''' , ':' , ',')</strong> correctly and controller gets hit but not for <strong>'/'</strong>.</p>
  
  <p><strong>Tried but not working :</strong></p>
  
  <pre><code>1) @RequestMapping(value = "/info/{id:.*}", method = RequestMethod.GET)
  2) @RequestMapping(value = "/info/{id}/**", method = RequestMethod.GET)
  3) @RequestMapping(value = "/info/**", method = RequestMethod.GET)
  </code></pre>