Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send HTTP post request using spring

Tags:

spring

What configuration do i need to send HTTP post request through spring. I am using java application , it's not a web project. Can i use spring to send HTTP post request? I google it but most almost all examples are using spring MVC. Can i use just spring to send HTTP post request ?

I found this bean on net but I don't know what to do after it. I am using spring3.2 and this post i think is of year 2008...

<bean id="httpClient" class="org.springbyexample.httpclient.HttpClientTemplate">
    <property name="defaultUri">
        <value><![CDATA[http://localhost:8093/test]]></value>
    </property>
</bean>


Any suggestions?

like image 634
Basit Avatar asked Jul 02 '13 11:07

Basit


People also ask

How do I request a post in Spring Boot?

Step 1: Click on Generate which will download the starter project. Step 2: Extract the zip file. Now open a suitable IDE and then go to File->New->Project from existing sources->Spring-boot-app and select pom. xml.


1 Answers

If you are using Spring 3.0+, it will be better to use RestTemplate for sending HTTP requests. Once you wire the RestTemplate (API), you can use different methods in it to send different types of HTTP requests.

like image 146
Dhanush Gopinath Avatar answered Sep 28 '22 01:09

Dhanush Gopinath