BasicNetwork.performRequest:意外响应代码 500 [英] BasicNetwork.performRequest: Unexpected response code 500 for

查看:77
本文介绍了BasicNetwork.performRequest:意外响应代码 500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Android Studio 中有此登录 Java 代码:

I have this Login Java code in my Android Studio:

private void loginUser(){
        pd = ProgressDialog.show(LoginActivity.this, "", "Loading...");
        StringRequest stringRequest = new StringRequest(Request.Method.POST, LOGIN_URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonResponse = new JSONObject(response);
                            System.out.println("JSON RESPONSE: " + jsonResponse.toString());
                            boolean success = jsonResponse.getBoolean("success");
                            if (success) {
                                launchHomeScreen();
                                pd.dismiss();
                                Toast.makeText(LoginActivity.this,"Welcome back " + username,Toast.LENGTH_LONG).show();

                                SharedPreferences sharedPref = getSharedPreferences("loginDatas", Context.MODE_PRIVATE);

                                SharedPreferences.Editor editor = sharedPref.edit();
                                editor.putString("username", username);
                                editor.putString("password", password);
                                editor.apply();
                            }
                            else {
                                loginButton.setBackgroundColor(0x73000000);
                                Toast.makeText(LoginActivity.this,"Wrong Username or Password!",Toast.LENGTH_LONG).show();
                                pd.dismiss();
                            }
                        }
                        catch (JSONException e) {
                            loginButton.setBackgroundColor(0x73000000);
                            e.printStackTrace();
                            pd.dismiss();
                            Toast.makeText(LoginActivity.this,response,Toast.LENGTH_LONG).show();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        loginButton.setBackgroundColor(0x73000000);
                        pd.dismiss();
                        System.out.println("Error: " + error);
                    }
                }){
            @Override
            protected Map<String,String> getParams(){
                Map<String,String> params = new HashMap<>();
                params.put(KEY_USERNAME,username);
                params.put(KEY_PASSWORD,password);
                return params;
            }

        };
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        requestQueue.add(stringRequest);
    }

但每次我在 Android 日志控制台中收到此错误时:

But everytime I get this error in my Android Log console:

 I tried so many things but everytime I try it, I get back: 04-20 07:44:18.463 3326-2366/com.lolol.gg E/Volley: [294] BasicNetwork.performRequest: Unexpected response code 500 for http://lollipop.xyz/login.php
    04-20 07:44:18.514 3326-3326/com.lolol.ggI/System.out: Error: com.android.volley.ServerError

有人有什么想法,如何解决我的问题?因为我尝试了很多东西...无论如何都行不通...奇怪的是:我经常测试服务器代码,它可以工作.当我使用我的 localwampserver 的 url 尝试 javacode 时它工作......当我尝试使用来自我的托管服务器的 url 它没有工作......在 2 个服务器中是相同的代码......

Has anybody an Idea, how to fix my problem? Because I tried many things...It won't work anyway... The weired thing is: I have tested the server code very often it works. When I try the javacode with the url for my localwampserver it works....When I try it with the url from my hostinger server it didn't work...In the 2 servers are the same codes...

推荐答案

获得 HTTP 响应代码 500 意味着您的应用成功联系了服务器,但服务器本身遇到了意外错误.

Getting an HTTP response code of 500 means that your app successfully contacted the server, but the server itself has encountered an unexpected error.

联系您的后端维护人员以了解服务器行为异常的原因,这很可能不是您可以在 Android 代码中修复的问题.

Contact your backend maintainer to see why the server is misbehaving, this most probably isn't an issue you can fix in your Android code.

这篇关于BasicNetwork.performRequest:意外响应代码 500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆