프레임워크/Spring

[Spring] HTTP request 보내기 (RestTemplate)

pythaac 2022. 1. 6. 13:37

아래 코드를 통해 Spring에서 HTTP request에 대한 response를 받을 수 있습니다.

 

public String Test(RestTemplateBuilder builder)
{
	// template builder를 통한 template 생성
    RestTemplate restTempate = builder.build();
    
    // url에 대한 response를 String 형식으로 수신
    final String url = "https://www.tistory.com/apis/blog/~~~";
    return this.restTemplate.getForObject(url, String.class);
}