1、通过HttpURLConnection发送http请求,得到返回的数据,(HttpURLConnection是URLConnection的子类,URLConnection代码写法和HttpURLC。http的三种请求方式?更多详情请大家跟着小编一起来看看吧!

http的三种请求方式

http的三种请求方式(1)

1、通过HttpURLConnection发送http请求,得到返回的数据,(HttpURLConnection是URLConnection的子类,URLConnection代码写法和HttpURLConnection代码一致,建议使用HttpURLConnection,HttpURLConnection请求使用JDK原生提供的net,无需其他jar包)

2、通过HttpClient发送http请求,得到返回数据(需要在pom.xml中添加依赖<dependency> <groupId>commons-httpclient<groupId> <artifactId>commons-httpclient<artifactId> <version>3.1<version><dependency>,此方法使用比较方便,比较广泛应用)

3、通过Socket发送http请求或,得到返回数据(http 的连接很简单,是无状态的。Socket请求使用JDK原生提供的net,无需其他jar包)