RestTemplate uriVariables not expanded

The currently-marked answer from user180100 is technically correct but not very explicit. Here is a more explicit answer, to help those coming along behind me, because the answer didn't quite make sense to me at first.

String url = "http://www.sample.com?foo={fooValue}";

Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("fooValue", "2");

// "http://www.sample.com?foo=2"
restTemplate.getForObject(url, Object.class, uriVariables);

There is no append some query string logic in RestTemplate it basically replace variable like {foo} by their value:

http://www.sample.com?foo={foo}

becomes:

http://www.sample.com?foo=2

if foo is 2.