什么是HTTClient应用
更新:HHH   时间:2023-1-7


什么是HTTClient应用,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

HttpClient 请求应用

  • maven导包

    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
  • httpClient的使用

	HttpClient httpClient = new HttpClient();
	PostMethod post = new PostMethod(url);
	RequestEntity requestEntity = new StringRequestEntity(req,"application/json","utf8");
	post.setRequestEntity(requestEntity);
	httpClient.executeMethod(post);

其中采用body进行传参,3.1版本中requestBody有多种:

  • ByteArrayRequestEntity

  • FileRequestEntity

  • InputStreamRequestEntity

  • MultipartRequestEntity

  • StringRequestEntity

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注天达云行业资讯频道,感谢您对天达云的支持。

返回大数据教程...