[java]代码库
public void postmethod(PostMethod postMethod, HttpClient client, int i) {
String resCode = null;
try {
client.executeMethod(postMethod);
int code = postMethod.getStatusCode();
if (code == HttpStatus.SC_OK) {
String info = null;
info = new String(postMethod.getResponseBodyAsString());
}
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");
/**
* 打印服务器返回的状态
*/
System.out.println("the post return value:" + postMethod.getStatusLine());
String typ = postMethod.getStatusLine().toString();
/**
* 打印结果页面
*/
// String response = new
// String(postMethod.getResponseBodyAsString().getBytes("UTF-8"));
// /**
// * 打印返回的信息
// */
// System.out.println("the getBytes() xml is:"+response);
// //打印返回的信息
resCode = postMethod.getResponseBodyAsString();
// 释放连接
} catch (IOException e) {
e.printStackTrace();
} finally {
postMethod.releaseConnection();
}
}
by: 发表于:2017-06-16 17:02:44 顶(0) | 踩(0) 回复
??
回复评论