Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

What is the meaning of UriComponentsBuilder?

Writer Matthew Barrera

I get an example UriComponentsBuilder while learning spring boot. I don't know the meaning of UriComponentsBuilder and the function of UriComponentsBuilder.

2 Answers

Yes, this used for constructing URI. Particularly useful when you want to invoke webservices in your class. Eg:

String baseUri = "/sample-uri"
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uri);
builder.queryParam("id", "1");
String uri= builder.build().encode().toUriString();

It is evident that you can pass additional params, to this. This provide a clean and efficient way of creating uris than writing those as plain text.

0

It is a factory class for getting instances of UriComponents which are helpful for constructing URIs.

Please go through the tutorial below, examples are also given here.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.