Sending HTTP POST Request In Java

后端 未结 8 1563
清歌不尽
清歌不尽 2020-11-21 11:17

lets assume this URL...

http://www.example.com/page.php?id=10            

(Here id needs to be sent in a POST request)

I want to se

8条回答
  •  生来不讨喜
    2020-11-21 11:57

    A simple way using Apache HTTP Components is

    Request.Post("http://www.example.com/page.php")
                .bodyForm(Form.form().add("id", "10").build())
                .execute()
                .returnContent();
    

    Take a look at the Fluent API

提交回复
热议问题