Java-通过POST方法轻松发送HTTP参数
HTTPGET
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
GETPOST?
connection.setRequestMethod("GET");connection.setRequestMethod("POST");HttpURLConnection
HUX布斯
梦里花落0921
随时随地看视频慕课网APP
相关分类