dimanche 15 mars 2015

How to set header while creating Spring's RestTemplate?

We can set a header to rest template while firing the call i.e. restTemplate.exchange(postUrl, HttpMethod.GET, entity, String.class);

where entity contains headers.


But for my requirement I want to set cookie header while creating the restTemplate itself and not while firing the actual call. I don't want to repeat the code of creating HttpEntity and setting headers to it.


Is there a way to set headers while creating restTemplate?


Aucun commentaire:

Enregistrer un commentaire