【问题标题】:500 Internal Server Error by post request android500内部服务器错误通过post请求android
【发布时间】:2015-03-05 21:40:14
【问题描述】:

HTTP post 请求会导致 500 internal server ERROR 吗?嗯,如果是这样,下面是我的代码,为什么我不断收到 500 内部服务器错误?我在代码中遗漏了什么?

               HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost((GetAllNewsURL));

                try {

                    // Add your data
                    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
                            1);

                    nameValuePairs.add(new BasicNameValuePair("pageNo", "0"));
                    nameValuePairs.add(new BasicNameValuePair("newsPerPage",
                            "0"));
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);
                    HttpEntity entity = response.getEntity();
                    stream = entity.getContent();
                    BufferedReader reader = new BufferedReader(
                            new InputStreamReader(stream));
                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }

谢谢,

【问题讨论】:

  • 堆栈跟踪是否存在?
  • stackoverflow.com/questions/14065236/… 能不能先看看这个,然后再说
  • 这是服务器端错误。
  • 感谢@Goutam 但stackoverflow.com/questions/14065236/… 在此链接中他们说可以纠正并有 2 个赞成票
  • 我知道这是服务器端错误。但有时浏览器会收到来自服务器的堆栈跟踪并将其显示给用户。顺便说一句,这取决于网络应用程序出了什么问题。

标签: android http-post


【解决方案1】:

对我来说,有时由于服务器端的问题,我必须将参数作为标头发送尝试相同的事情

 HttpPost httppost = new HttpPost((GetAllNewsURL+"?pageNo=0&newsPerPage=0"));

或者只传递一个参数作为标题希望它有效

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-30
    • 1970-01-01
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 2015-09-20
    相关资源
    最近更新 更多