我想創建一個用戶登錄頁面,我得到這個錯誤,而我試圖register.I想有一個與JSON對象part.I試圖尋找一個問題在論壇上的其他答案,但似乎沒有解決我的問題。請你幫我解決這個問題。感謝提前。BasicNetwork.performRequest:意外的響應代碼500凌空
public void registercheck(final String name, final String email, final String password) {
String tag_req = "Register_request";
pdialog.setMessage("Registering ...");
showDialog();
StringRequest strR = new StringRequest(Request.Method.POST, Appconfig.LOGIN_URL, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
hidedialog();
try {
JSONObject jsp = new JSONObject(s);
boolean error = jsp.getBoolean("error");
if (!error) {
String uid = jsp.getString("uid");
JSONObject user = jsp.getJSONObject("user");
String name = user.getString("name");
String email = user.getString("email");
String created_at = user.getString("created_at");
db.addUser(name, email, uid, created_at);
session.setLogin(true);
Intent i = new Intent(Register.this, MainActivity.class);
startActivity(i);
finish();
} else {
String error_msg = jsp.getString("error_msg");
Toast.makeText(Register.this, error_msg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.e(TAG, volleyError.getMessage());
}
}) {
@Override
public Map<String, String> getParams() {
Map<String, String> p = new HashMap<String, String>();
p.put("name", name);
p.put("tag", "register");
p.put("email", email);
p.put("password", password);
return p;
我的日誌貓
15.407 11021-11440/example.com.login E/Volley﹕ [2407] BasicNetwork.performRequest: Unexpected response code 500 for http://busappandroid.gear.host/
記錄'request'對象和'response'並顯示請求方法簽名的詳細信息 –
您的代碼中您尚未關閉字符串請求,或者您粘貼的代碼還有一些內容請檢查並更正因爲方法沒有正確關閉 –