使用的 xutils
出现标题中的错误
原因:没有添加 Cookie
1 params.addHeader("Cookie", CurrentUserSettings.getCookies());
加上之后问题解决
Cookie通过以下方式获取
final HttpUtils httpUtils = new HttpUtils(); params.setPriority(Priority.BG_TOP); httpUtils.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() { @Override public void onSuccess(ResponseInfo<String> responseInfo) { DefaultHttpClient defaultHttpClient = (DefaultHttpClient) httpUtils.getHttpClient(); List<Cookie> cookies = defaultHttpClient.getCookieStore().getCookies(); if (cookies.size() > 0) { CurrentUserSettings.setCookies(cookies.get(0).getName() + "=" + cookies.get(0).getValue()); } }
}