一开始我就测试了一下连不上。。个人问题是
基本地址:服务器ip地址:端口号/Web项目逻辑地址+目标页面(Servlet)的url-pattern
private String baseURL = "http://10.0.2.2:8080/test/AddMessage";
这个是个人的服务器的地址,,我尝试了多个ip地址,,有127.0.0.1 有localhost有实际的地址都不行 apache
10-24 23:28:47.004: W/System.err(1919): org.apache.http.conn.HttpHostConnectException: Connection to http://10.0.2.2:8080 refused 服务器
个人链接语句。。是一个post请求,, post
HttpEntity requestHttpEntity = new UrlEncodedFormEntity(
pairList);
// URL使用基本URL便可,其中不须要加参数
HttpPost httpPost = new HttpPost(baseURL);
// 将请求体内容加入请求中
httpPost.setEntity(requestHttpEntity);
// 须要客户端对象来发送请求
HttpClient httpClient = new DefaultHttpClient();
// 发送请求
HttpResponse response = httpClient.execute(httpPost);
// 显示响应
showResponseResult(response); 测试
麻烦大神们给点意见!! url