package com.qf.okhttp;
import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class Demo02 {
public static void main(String[] args) {
String path = "http://localhost:8080/day251/LoginServlet?username=admin&password=123456";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(path).build();
try {
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
String s = response.body().string();
System.out.println(s);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class Demo02 {
public static void main(String[] args) {
String path = "http://localhost:8080/day251/LoginServlet?username=admin&password=123456";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(path).build();
try {
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
String s = response.body().string();
System.out.println(s);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}