url="http://192.168.1.168:8080/sshop_Server/servlet/LoginServlet?username=username&password=password"

解决方案 »

  1.   

    其中username=username&password=password是动态添加的
      

  2.   

    username=username&password=password????
    你这里面username和password都放到字符串里面去了,怎么传值进去呢。。
    改成:url="http://192.168.1.168:8080/sshop_Server/servlet/LoginServlet?username="+username+"&password="+password;
     
      

  3.   

    那是我在运行过程中在debug时取出来的url的值
      

  4.   

    看你URL应该使用get方法吧、你现在用的post 当然报错了
    这是之前写的,你看下
    String uriAPI="http://10.255.153.46:8080/Registe/servlet/reg?user="+s0+"&password="+s1;
    String strResult;
    HttpGet httpRequest=new HttpGet(uriAPI);//创建HTTP Get连接 
    try {
    HttpClient client = new DefaultHttpClient();  
    client.execute(httpRequest);
    HttpResponse httpResponse=new DefaultHttpClient().execute(httpRequest);
    if(httpResponse.getStatusLine().getStatusCode()==200){ //当访问服务器有效时
    strResult=EntityUtils.toString(httpResponse.getEntity()).trim();
    Log.d("Infor","新用户:"+strResult);
    if(strResult.equals("Y")){
    new AlertDialog.Builder(Register1.this).setTitle(" 提示")   .setMessage("注册成功!!")   .setPositiveButton("确定", null)   .show();}
    else if(strResult.equals("N")){
    new AlertDialog.Builder(Register1.this).setTitle(" 提示")   .setMessage("注册失败,该账号已被使用!!")   .setPositiveButton("确定", null)   .show();}
    }
    else{
         //System.out.println(httpResponse.getStatusLine().getStatusCode());
         Log.d("Infor","连接失败");
        
         }
         } catch (ClientProtocolException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
         System.out.println(e);
         } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
         System.out.println(e);
         }
      

  5.   

    代码没问题,但是我没看到你在httpPost那里哪边添加参数值了啊
    要是代码中的方法的参数url为你debug中的值,貌似这是HttpGet方式请求的啊,httpPost就改成httpGet
    如果你一定要用post方式,需要httpPost.setEntity(HttpEntity entity);
      

  6.   

    post请求的时候参数不应该设置在url里,楼上说的都是这个问题
      

  7.   

    问题差不多我的url是这么设置的但执行操作就出现错误地址在浏览器执行却没有任何问题
    URI uri = new URI(httpUrl);
    request.setURI(uri);
    问题出在哪都找不到因为客户端无错误时后台错了