我有一个名为ConnectionToOracle的java Web项目。我有一个名为Sign_Up_Servlet的servlet。
所以我有以下代码:
private static String url_sign_up_execute
= "http://10.11.201.84:8084//ConnectionToOracle/Sign_Up_Servlet";
private class GetSignUpStatus extends AsyncTask<String, Integer, String> {
ProgressDialog pDialog = new ProgressDialog(Sign_Up.this);
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pDialog.setMessage("Please wait...");
pDialog.show();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
pDialog.dismiss();
if (json == null) {
pDialog.dismiss();
Toast.makeText(
getApplicationContext(),
"Unable to Perform Your Request.Server Is Temporarily Unreachable! Please Try Later.",
Toast.LENGTH_LONG).show();
}
else{
if(pErrorFlag.equals("N"))
Toast.makeText(getApplicationContext(),"Sign Up successfully done ", Toast.LENGTH_LONG).show();
else if( pErrorFlag.equals("Y") )
Toast.makeText(getApplicationContext(), pErrorMessage, Toast.LENGTH_LONG).show();
}
}
@Override
protected String doInBackground(String... args) {
// TODO Auto-generated method stub
List<NameValuePair> params = new ArrayList<NameValuePair>();
// params.add(new BasicNameValuePair("pDeviceId",deviceId_str));
// params.add(new BasicNameValuePair("pMobileNo",mobile_no_str));
// params.add(new BasicNameValuePair("pUserId",user_id_str));
// params.add(new BasicNameValuePair("pPassword",password_str));
// params.add(new BasicNameValuePair("pPinCode",pin_code_str));
// params.add(new BasicNameValuePair("pDeviceId","1"));
// params.add(new BasicNameValuePair("pMobileNo","1"));
// params.add(new BasicNameValuePair("pUserId","1"));
// params.add(new BasicNameValuePair("pPassword","1"));
// params.add(new BasicNameValuePair("pPinCode","1"));
//
json = jsonParser.makeHttpRequest(url_sign_up_execute, "POST", params);
// Log.d("All Login Responese: ", json.toString());
try {
if (json != null) {
jsonArray = json.getJSONArray(TAG_SIGN_UP);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject c = jsonArray.getJSONObject(i);
pErrorFlag = c.getString(TAG_ERROR_FLAG);
pErrorMessage = c.getString(TAG_ERROR_MESSAGE) ;
}
// Log.d("error Code", errorCode);
} else {
Log.d("Server Unreachable",
"Unable to Perform Your request.Server Is Unreachable! Please Try Later.");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
我正在向“http://10.11.201.84:8084//ConnectionToOracle/Sign_Up_Servlet”网址发送http请求。但我得到的json值为null。为什么?我该如何解决这个错误?
答案 0 :(得分:1)
尝试使用“http://10.11.201.84:8084/ConnectionToOracle/Sign_Up_Servlet”代替“http://10.11.201.84:8084//ConnectionToOracle/Sign_Up_Servlet”。可能问题是在端口号后面加了一个“/”.....