@PathVariable not accepting trailing whitespace in Spring Boot
<p>We are using Spring Boot to build rest api, I am facing issue in @PathVariable in Spring Boot rest api. It is not accepting trialing whitespace in path parameter in the URL. </p>

<p>This URL works:</p>

<pre><code>https://foo.com/api/v1/pen/?param1=foobar
</code></pre>

<p>But below url doesn't work, and it removes trailing whitespace:</p>

<pre><code>https://foo.com/api/v1/pen /?param1=foobarfoo
</code></pre>

<p>Yes, it may look strange but we have requirements as this api does lot of database search and even whitespace with without whitespace affects the output.
This is how my Request Mapping looks like:</p>

<pre><code>@RequestMapping(value="api/v1/{sentenceToSearch}",method=RequestMethod.GET,produces={MediaType.APPLICATION_JSON})
</code></pre>

<p>I searched many questions in stackoverflow like:</p>

<p><a href="https://stackoverflow.com/questions/23333330/controller-pathvariable-bind-removes-ending-space">Controller Pathvariable bind removes ending space</a></p>

<p>But above question doesn't have solution. Also tried various questions which was having query to prevent trimming of "." from url and based on that I tried to add below code:</p>

<pre><code>@Configuration
  protected static class AllResources extends WebMvcConfigurerAdapter {

      @Override
      public void configurePathMatch(PathMatchConfigurer matcher) {
          matcher.setUseRegisteredSuffixPatternMatch(true);
      }

  }
</code></pre>

<p>But it works for "." not for special characters, also I tried adding expression like this in request mapping: <code>{sentenceToSearch:.+}</code> but all of them not working. </p>

<p>Can someone help me in this?</p>