java - HttpURLConnection、openConnection 和 setRequestMethod ("GET"

标签 java android httpurlconnection

我目前正在尝试理解下面每个代码背后的逻辑。请告诉我我是否正确并回答我的困惑。

urlConnection = (HttpURLConnection) url.openConnection(); 
//connection object is created. However, do not understand 
//"manipulate parameters that affect the connection to the remote resource."
urlConnection.setRequestMethod("GET");
//set the method for the URL request. Not sure what that means! 
//there are other strings that could be used, but not sure what each means, 
//and couldn't the Java documentations didn't seem to have explanations either
urlConnection.connect();
//the actual connection the the remote object is made

最佳答案

这个问题与Java完全无关。你需要的是了解HTTP协议(protocol)并做一些全面的阅读。我建议从

开始

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

然后阅读:

https://www.rfc-editor.org/rfc/rfc7230

关于java - HttpURLConnection、openConnection 和 setRequestMethod ("GET",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27584751/

相关文章:

java - 强制转换会影响instanceof操作的结果吗?

java - 灵活的分支/列表数据结构?

java - SWT 中的 PropertyChangeSupport。如何监听通知,例如在表中?

android - 单击删除按钮时如何刷新 ListView

java - 更新gui中的Jtable内容而不重新启动重绘表格的方法?

java - 如何使用 JBPM 4.4 的 jpdl 获取 ProcessDefinition?

android - android 中过度滚动的视觉指示

android - Android 4.4 Kitkat 中的内部文件选择器

java - 通过 URLConnection 写入图像

java - 如何从 Java 执行 HTTP 清除?