Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Http Post返回200但不工作_Android_Http_Post - Fatal编程技术网

Android Http Post返回200但不工作

Android Http Post返回200但不工作,android,http,post,Android,Http,Post,首先,我必须说我对HTTP非常陌生。我要在我父母的餐馆网站上提交一个帖子请求,以便从我的应用程序中注册一个新用户 网站地址如下(西班牙语): 据我所知,post请求具有以下值对: <form name="formulario" method="post" action="index.asp?Opc=Registro&Sub=Nuevo" > <input type="text" size="20" name="nombre" value="" style="bac

首先,我必须说我对HTTP非常陌生。我要在我父母的餐馆网站上提交一个帖子请求,以便从我的应用程序中注册一个新用户

网站地址如下(西班牙语):

据我所知,post请求具有以下值对:

 <form name="formulario" method="post" action="index.asp?Opc=Registro&Sub=Nuevo" >

 <input type="text" size="20" name="nombre" value="" style="background-color:#f5f7fe" />                              
 <input type="text" size="30" name="apellidos" value="" style="background-color:#f5f7fe" />
 <input type="text" size="30" name="direccion" value="" style="background-color:#f5f7fe" />
 <input type="text" size="20" name="nif" id="nif" style="background-color:#f5f7fe" value="" />
 <input type="text" size="30" name="email" id="email" value="" style="background-color:#f5f7fe"/>
 <input type="text" size="20" name="telefono" value=""  style="background-color:#f5f7fe" />
 <input type="text" size="10" name="clave" value="" style="background-color:#f5f7fe" />      
 <input type="checkbox" value="S" name="correo"  checked="checked"  />
换成

  data = EntityUtils.toString(response.getEntity());

HTML摘录提到以下地址:
index.asp?Opc=Registro&Sub=Nuevo


显然,您是在
index.asp?Opc=Registrado
上提出请求的,这是不同的,因为缺少
&Sub=Nuevo
部分。(Nuevo值可能表示创建了一个新项目)。

您不需要url中的
&Sub=Nuevo
部分吗?您这样认为吗?我会尝试…而且,显然在那篇文章中,200可能并不意味着一切正常,因为似乎有一些服务器端验证。返回200,但附加的网页解释了错误。我建议您尝试查看那里的错误消息。(例如,您可以在webview中显示它。)我以字符串形式获取附加网页的HTML。如果我扫描代码,我能找到错误吗?在网络视图中显示它,你会看到错误。虽然这在技术上是正确的,但它不是一个答案,而是一个注释。
private StringBuilder inputStreamToString(InputStream is) {
    String line = "";
    StringBuilder total = new StringBuilder();

    // Wrap a BufferedReader around the InputStream
    BufferedReader rd = new BufferedReader(new InputStreamReader(is));

    // Read response until the end
    try {
        while ((line = rd.readLine()) != null) { 
            total.append(line); 
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // Return full string
    return total;
}
 data = inputStreamToString(response.getEntity().getContent());
  data = EntityUtils.toString(response.getEntity());