httpclient:PostMethod方式进行服务器请求

public void post(String url) {
		try {
			HttpClient client = new HttpClient();
			PostMethod post = new PostMethod(url);
			int status = client.executeMethod(post);
			if (status == 200) {
				Logger.getLogger(HttpClientUtil.class).info("请求成功");
			} else {
				Logger.getLogger(HttpClientUtil.class).info("请求失败");
			}
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

你可能感兴趣的:(httpclient)