简体   繁体   中英

Using RestTemplate getForObject method

I have to call a REST web-service and I am planning to use Rest Template.

I looked at examples on how to make a GET request but I don't really understand how to use

the getForObject method

In my case

request is a string

response=is an arraylist<URI>

I have create a class named ObjectExchanged

   public class ObjectExchanged {
@JsonProperty
String request;
ArrayList<URI> response;
  }

Then

    getRestTemplate()).getForObject(URL, ObjectExchanged.class, ??);

What Should I put in the third field

Why you want 3rd field??

getForObject(uri,ObjectExchanged.class); will work

getForObject(java.lang.String s, java.lang.Class<T> tClass, java.lang.Object... objects) throws org.springframework.web.client.RestClientException; 
getForObject(java.lang.String s, java.lang.Class<T> tClass, java.util.Map<java.lang.String,?> stringMap) throws org.springframework.web.client.RestClientException; 
getForObject(java.net.URI uri, java.lang.Class<T> tClass) throws org.springframework.web.client.RestClientException; 

these are the 3 type of implementation

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