如何使用java.net.URLConnection触发和处理HTTP请求

问题:

Use of java.net.URLConnection is asked about pretty often here, and the Oracle tutorial is too concise about it. 在这里常常会问到使用java.net.URLConnection状况,而Oracle教程对此过于简洁。 html

That tutorial basically only shows how to fire a GET request and read the response. 该教程基本上仅显示如何触发GET请求并读取响应。 It doesn't explain anywhere how to use it to among others perform a POST request, set request headers, read response headers, deal with cookies, submit a HTML form, upload a file, etc. 它没有任何地方说明如何使用它来执行POST请求,设置请求标头,读取响应标头,处理cookie,提交HTML表单,上传文件等。 java

So, how can I use java.net.URLConnection to fire and handle "advanced" HTTP requests? 所以,如何使用java.net.URLConnection来触发和处理“高级” HTTP请求? api


解决方案:

参考一: https://stackoom.com/question/Bico/如何使用java-net-URLConnection触发和处理HTTP请求
参考二: https://oldbug.net/q/Bico/How-to-use-java-net-URLConnection-to-fire-and-handle-HTTP-requests
相关文章
相关标签/搜索