<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> URI target = UriComponentsBuilder.newInstance() .scheme("http") .host("example.com") .queryParam("foo", "b&r") .build() .encode() .toUri(); System.out.println(target);// http://example.com?foo=b%26r