简体   繁体   中英

Pass parameters to URL placeholders in java

I am getting the URL dynamically which has few placeholders. But i need to pass the parameters to the placeholders.

Below is the URL which i am getting dynamically

http://example.com/name/{name}/age/{age}

i need to pass parameters for name and age for the above url. How can we achieve that using java.

I guess you are looking Rest Client to call this URL and get response.

http://example.com/name/ {name}/age/{age}

String resourceURL = "http://example.com/name";
ResponseEntity<String> response = restTemplate.getForEntity(resourceURL + "/swarit/age/20", String.class);

I would also suggest to do little research before posting question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM