67,513
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
try {
HttpClient client = new HttpClient();
HttpMethod method = getPostMethod(); // 使用POST方式提交数据
int statusCode = client.executeMethod(method);
// 打印服务器返回的状态
String state = method.getStatusLine().toString();
System.out.println("服务器返回的状态:" +state +" 状态码:" +statusCode);
// 打印结果页面
String response = new String(method.getResponseBodyAsString()
.getBytes("gb2312"));
// 打印返回的信息
System.out.println("结果页面" + response);
method.releaseConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
private static HttpMethod getPostMethod() {
String url = "http://10.0.0.32/appOper/dcAppStyle!monitorAppStyle.action";
HttpMethodParams p = new HttpMethodParams();
p.setParameter( "applicaiton ", "9527 ");
HttpMethod post = new PostMethod(url);
post.setParams(p);
return post;
}