public class UlistClient {
public static String getClient(String name,String passrword){
String path="http://172.20.74.26:8080/fuwuqi/Fuwuqi?name="+name+"&preass="+passrword;
HttpClient client=new DefaultHttpClient();
HttpGet get=new HttpGet(path);
try {
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode()==200) {
return EntityUtils.toString(response.getEntity());
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static String PostClient(String name, String password) {
String path="http://172.20.74.26:8080/fuwuqi/Fuwuqi";
HttpClient client=new DefaultHttpClient();
try {
HttpPost post=new HttpPost(path);
List<NameValuePair> parameters=new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("name",name));
parameters.add(new BasicNameValuePair("preass",password));
HttpEntity entity=new UrlEncodedFormEntity(parameters);
post.setEntity(entity);
HttpResponse response = client.execute(post);
if (response.getStatusLine().getStatusCode()==200) {
return EntityUtils.toString(response.getEntity());
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
httpclient_get_post
最新推荐文章于 2023-08-10 14:24:27 发布