public class IllegalArgumentException
抛出的异常表明向方法传递了一个不合法或不正确的参数。
参数不对。你好像就是把参数拼接在url后面的啊。。。
public void userloginLoda() {
myapp = (MyApplication)this.getApplication();
cid =myapp.getInstance().getCid();
Toast.makeText(login.this, "CID:"+myapp.cid, Toast.LENGTH_SHORT).show();
//实例化httpCilent
JSONArray jsonarray = new JSONArray();//json数组
httpCilent = new DefaultHttpClient();
try {
//设置请求的路径
httpPost = new HttpPost(url+"/JSONServlet");
//创建一个用户,用于向服务端发送数据时,存放的实体
// JSONObject json = new JSONObject();
JSONObject commonJson = new JSONObject();
try {
//将用户填写的账号和密码存放到JSONObject中
PhoneState phoneState = new PhoneState();
commonJson.put("loginId",phoneState.getLoginId() );
commonJson.put("loginKey",phoneState.getLoginKey() );
// commonJson.put("deviceId",phoneState.getTelephonyManager());
commonJson.put("deviceId",phoneState.getDeviceId());
commonJson.put("version",phoneState.getVersion());
commonJson.put("deviceType",phoneState.getDeviceType() );
//组装共有参数
//url = url + "&commonParams=" + commonJson.toString();
Toast.makeText(login.this, "拼接共有参数:" + url, Toast.LENGTH_LONG).show();
//组装业务参数
commonJson.put("cid", cid);
commonJson.put("phoneNumber", login_accountid.getText().toString());
commonJson.put("password", login_password.getText().toString());
// json.put("params", paramJson.toString());
url = url + "¶ms=" + commonJson.toString();
Toast.makeText(login.this, "拼接业务参数:" + url, Toast.LENGTH_LONG).show();
} catch (JSONException e1) {
e1.printStackTrace();
}
//设置请求体
httpPost.setEntity(new StringEntity(commonJson.toString()));
//执行请求获取响应
response = httpCilent.execute(httpPost);
//如果响应的状态码为200时,表示请求响应成功
if(response.getStatusLine().getStatusCode() == 200){
//获取响应的实体数据
entity = response.getEntity();
StringBuffer sb = new StringBuffer();
// 通过reader读取实体对象包含的数据
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
//循环读取实体里面的数据
String s = null;
while((s = reader.readLine()) != null){
sb.append(s);
}
//创建一个JSONObject对象存放从服务端获取到的JSONObject数据
JSONObject datas = new JSONObject(sb.toString());
//创建一个boolean变量用于存放服务端的处理结果状态
boolean result = datas.getBoolean("result");
System.out.println(datas.toString());
if(result== true){
//创建一个intent用于页面之间的跳转
Intent intent = new Intent(this, MainActivity.class);
//开启跳转
startActivity(intent);
}else{//如果服务端的处理结果状态为false时
Toast.makeText(this, "用户不存在或密码错误", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
}
} 直接进catch exception里面了
你用POST方式请求试试,不要用GET方式