2 zy summer zy_summer 于 2017.09.11 09:59 提问

最新版的httpclint怎么保持会话

4.x之后defaulthtppclint就不推荐使用了 那新的怎么保持会话
保存session呢

3个回答

zy841958835
zy841958835   Ds   Rxr 2017.09.11 09:59
已采纳

static CookieStore cookieStore = new BasicCookieStore();

private static CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
private static HttpClientContext context = new HttpClientContext();

请求的时候:
response = httpClient.execute(get, context);

Zoe_zl
Zoe_zl   2017.09.11 10:01

static CookieStore cookieStore = new BasicCookieStore();

private static CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
private static HttpClientContext context = new HttpClientContext();

请求的时候:
response = httpClient.execute(get, context);

qq_34664963
qq_34664963   2017.09.11 10:19

static CookieStore cookieStore = new BasicCookieStore();

private static CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
private static HttpClientContext context = new HttpClientContext();

请求的时候:
response = httpClient.execute(get, context);

Csdn user default icon
上传中...
上传图片
插入图片