android项目连接服务器连不上。

我的项目连接服务器时,没有报错但就是不能将数据传过去。权限也加了,路径在浏览器上也ok。就是连不上啊。求大神指教。

一步步用Log打印看看,到底哪里不对

你ping一下服务器,看看能访问吗

你先用浏览器,调试 是否可以发送数据,排除服务器不能接收问题,其次在调试客户端。调试客户端,先做连接测试,其次在发数据,实在不行,
简化排除法,服务器端写最简单接收返回程序,不要加权限等外在因素。如何可以访问,证明是权限之类外在因素问题,如果不是,客服端程序问题。

//servlet的代码
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Test extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String str=request.getParameter("hh");
    if(str.equals("hh")){
        out.println("kkkkkkkkkkkkkkkkkkkkkk");
    }
    out.flush();
    out.close();
}


public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    doGet(request,response);
}

}
//Android端的代码
package com.example.ceshi;

import org.apache.http.Header;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    haha();
}

public void haha(){
    String path = "http://localhost:8080/test/servlet/Test";
    RequestParams params = new RequestParams(); 
    params.put("hh","hh");
    AsyncHttpClient client = new AsyncHttpClient();
    client.post(path, params, new AsyncHttpResponseHandler(){
        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2,
                Throwable arg3) {
            // TODO Auto-generated method stub
            Toast.makeText(MainActivity.this, "服务器出错!", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {

            Toast.makeText(MainActivity.this, "服务器成功!", Toast.LENGTH_LONG).show();
        }

    });
}

}
以上的网络链接可以,但是不能进行数据传输。