title: Why is Spring de-coding + (the plus character) on application/json get requests? and what should I do about it?
body: <p>I have a Spring application that receives a request like <code>http://localhost/foo?email=foo+bar@example.com</code>. This triggers a controller that roughly looks like this:</p>
  
  <pre><code>@RestController
  @RequestMapping("/foo")
  public class FooController extends Controller {
      @GetMapping
      public void foo(@RequestParam("email") String email) {
         System.out.println(email)
      }
  }
  </code></pre>
  
  <p>By the time I can access <code>email</code>, it's been converted to <code>foo bar@example.com</code> instead of the original <code>foo+bar@example.com</code>. According to <a href="https://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-or-20/2678602">When to encode space to plus (+) or %20?</a> this should only happen in requests where the content is <code>application/x-www-form-urlencoded</code>. My request has a content type of <code>application/json</code>. The full MIME headers of the request look like this:</p>
  
  <pre><code>=== MimeHeaders ===
  accept = application/json
  content-type = application/json
  user-agent = Dashman Configurator/0.0.0-dev
  content-length = 0
  host = localhost:8080
  connection = keep-alive
  </code></pre>
  
  <p>Why is Spring then decoding the plus as a space? And if this is the way it should work, <a href="https://stackoverflow.com/questions/50432395/whats-the-proper-way-to-escape-url-variables-with-springs-resttemplate">why isn't it encoding pluses as <code>%2B</code> when making requests</a>? </p>
  
  <p>I found this bug report about it: <a href="https://jira.spring.io/browse/SPR-6291" rel="noreferrer">https://jira.spring.io/browse/SPR-6291</a> which may imply that this is fixed on version 3.0.5 and I'm using Spring > 5.0.0. It is possible that I may misinterpreting something about the bug report.</p>
  
  <p>I also found this discussion about RestTemplate treatment of these values: <a href="https://jira.spring.io/browse/SPR-5516" rel="noreferrer">https://jira.spring.io/browse/SPR-5516</a> (my client is using RestTemplate).</p>
  
  <p>So, my questions are, why is Spring doing this? How can I disable it? Should I disable it or should I encode pluses on the client, even if the requests are json?</p>
  
  <p>Just to clarify, I'm not using neither HTML nor JavaScript anywhere here. There's a Spring Rest Controller and the client is Spring's <code>RestTemplate</code> with <code>UriTemplate</code> or <code>UriComponentsBuilder</code>, neither of which encode the plus sign the way Spring decodes it.</p>