title: How to encode a portion of path in URI using UriComponentsBuilder?
body: <p>I have a path that looks like this: <code>/service/method/{id}/{parameters}</code> which I call using restTemplate, where <code>/service/method</code> is a microservice, <code>{id}</code> is some id that I need to ask for, and <code>{parameters}</code> is a link that looks something like this: <code>/home/floor/kitchen/</code> that I use for mapping in a JsonNodeTree later in the service/method microservice. </p>
  
  <p>I am trying to use</p>
  
  <pre><code>    Map&lt;String, String&gt; uriVariables = new HashMap&lt;String, String&gt;();
              uriVariables.put("id", "5080572115");
              uriVariables.put("parameters", "/home/floor/kitchen/");
  
              UriComponents uriComponents = UriComponentsBuilder.newInstance().scheme("http").host("service/methods/{id}").
              path("/{parameters}").buildAndExpand(uriVariables).encode();
  String finalURI = uriComponents.toUriString();
  return restTemplate.getForObject(finalURI, Integer.class);
  </code></pre>
  
  <p>But what I get is the whole link <a href="http://service/methods/" rel="nofollow noreferrer">http://service/methods/</a>{id}/{parameters} encoded. And what I need is only a portion of it ({parameters}) to be encoded so I can parse the other part of the url into the RestTemplate. 
  To be clear again, I need to parse service/methods/{id} into RestTemplate, and decode {parameters} later to use as a path for the JsonNodeTree.</p>
  
  <p>edit: I am aware of queries but couldn’t find a solution of encoding a portion of a path.</p>