URL url=new URL(path);
//得到httpurlconnection对象
HttpURLConnection httpURLConnection= (HttpsURLConnection) url.openConnection();
//设置请求方式post
httpURLConnection.setRequestMethod(“POST”);
//设置连接时间
httpURLConnection.setConnectTimeout(5000);
//设置http请求数据类型
httpURLConnection.setRequestProperty(“Content-Type”,“application/x-www-form-urlencoded”);
//数据
String data=“mobile=”+name1+"&password="+pwd1;
//告诉服务器我给你提交的数据有多大
httpURLConnection.setRequestProperty(“Content-Length”,data.length()+"");
//要记得指定给服务器写入数据的开关打开
httpURLConnection.setDoInput(true);
//开始往服务器传入数据
httpURLConnection.getOutputStream().write(data.getBytes());