1

cookie 没有被设置,下面是代码。

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpPostRequest = new HttpPost(URL);

CookieStore cookieStore = new BasicCookieStore(); 
BasicClientCookie cookie = new BasicClientCookie("Name", "value");
cookieStore.addCookie(cookie); 

HttpContext localContext = new BasicHttpContext();

localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
httpPostRequest.setEntity(fileentity);

HttpResponse response = (HttpResponse) httpclient.execute(httpPostRequest,localContext);

也试过

httpclient.setCookieStore(cookieStore); 

但没有任何效果。

4

0 回答 0