Java-通过POST方法轻松发送HTTP参数
HTTP
GET
void sendRequest(String request){ // i.e.: request = "http://example.com/index.php?param1=a¶m2=b¶m3=c"; URL url = new URL(request); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setInstanceFollowRedirects(false); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "text/plain"); connection.setRequestProperty("charset", "utf-8"); connection.connect();}
POST
GET
POST
?
connection.setRequestMethod("GET");
connection.setRequestMethod("POST");
HttpURLConnection
梦里花落0921
相关分类