URL authUrl1 = new URL(
"http://10.1.12.83:8080/DataSpider/clientLogin?Email=test&Passwd=test123");
HttpURLConnection authCon1 = (HttpURLConnection) authUrl1
.openConnection();
authCon1.setRequestMethod("POST");
authCon1.setReadTimeout(500);
authCon1.setUseCaches(false);
authCon1.setDoInput(true);
authCon1.setDoOutput(true);
authCon1.connect();
int responseCode1 = authCon1.getResponseCode();
if (responseCode1 >= 200 && responseCode1 <= 400) {
logger.info("鉴权1,获得通行证成功!");
BufferedReader reader1 = new BufferedReader(
new InputStreamReader(authCon1.getInputStream(),
"UTF-8"));
if (reader1.read() != -1) {
SID = reader1.readLine();
System.out.println("------------==========="+SID);
String[] arr=SID.split(" //r//n");
System.out.println("ddddddddddd-----------======="+arr[0]);
reader1.close();
servlet里面写http连接的代码
最新推荐文章于 2024-04-26 22:47:24 发布