当我单击登录时,我遇到了Java Volley的问题
private void Login(){
String url = "api.matraindonesia.com/login";
RequestQueue requestQueue = Volley.newRequestQueue(this);
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (response.trim().equals("success")){
Toast.makeText(getApplicationContext(),"Login Successfully!",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),"Login Failed!",Toast.LENGTH_LONG).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),"this error:"+ error.toString(),Toast.LENGTH_LONG).show();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("email",etEmail.getText().toString().trim());
params.put("password",etPassword.getText().toString().trim());
return super.getParams();
}
};
requestQueue.add(stringRequest);
}
com.android.volley.VolleyError:java.lang.RuntimeException:错误的网址
答案 0 :(得分:1)
您需要在开头使用http://
或https://
或url
String url = "http://api.matraindonesia.com/login";
,或者您的服务器是否使用 SSL
String url = "https://api.matraindonesia.com/login";