通用域名格式。安卓截击解析错误:org。json。JSONException:值<!java类型的DOCTYPE。无法将lang.String转换为JSONObject
我有一个错误。尽管有一些针对java的解决方案。String无法转换为JSONObject,我无法用现有的解决方案解决我的问题。 以下是我在LoginActivity的onCreate()中的代码:
JSONObject jsonObject=new JSONObject();
try{
jsonObject.put("username",username);
jsonObject.put("password",password);
jsonObject.put("isWeb",false);
jsonObject.put("grant_type","passo");
jsonObject.put("accepttc",true);
jsonObject.put("client_id","MyClientMobileApp");
jsonObject.put("client_secret","myClinet@mobileapp");
jsonObject.put("devicetype","ios");
}catch(JSONException e){
e.printStackTrace();
}
Response.Listener<String> responseListener=new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(LoginActivity.this,"All went well.",Toast.LENGTH_LONG).show();
Log.d("REsponse: ",response.toString());
}
};
Response.ErrorListener errorListener=new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(LoginActivity.this,"Something went wrong...",Toast.LENGTH_LONG).show();
Log.d("REsponse: ",error.toString());
}
};
LoginRequest loginRequest=new LoginRequest(responseListener,jsonObject,errorListener);
RequestQueue queue= Volley.newRequestQueue(LoginActivity.this);
queue.add(loginRequest);
}
//Code in LoginRequest.java
public class LoginRequest extends JsonObjectRequest {
private static final String LOGIN_REQUEST_URL ="http://mywebapp.com:8080";
public LoginRequest(Response.Listener responseListener, JSONObject jsonObject, Response.ErrorListener errorListener){
super(Method.POST, LOGIN_REQUEST_URL, jsonObject, responseListener, errorListener);
}
}
到目前为止,我已经在安卓 profiler中获得了响应代码200(成功)。 但是“出了点问题……”我想得到“一切顺利”我们将非常感谢您的任何帮助。多谢各位
共 (0) 个答案