Java 8 HttpClient 4.5 使用 BasicCookieStore 处理 cookie
Java 8 HttpClient 4.5 Handling cookies with BasicCookieStore
我该怎么做?
HttpClientBuilder client = HttpClientBuilder.create();
HttpResponse response = null;
HttpClientContext context = HttpClientContext.create();
BasicCookieStore cookieStore = new BasicCookieStore();
client.setDefaultCookieStore(cookieStore);
response = client.build().execute(get);
cookieStore = context.getCookieStore();
它告诉我:无法将 CookieStore 转换为 BasicCookieStore。我不能使用 CookieStore 接口而不是 BasicCookieStore,因为在我的另一个 类 中显示 "Interfaces can't be instantiated".
我认为选角会对你有所帮助。
BasicCookieStore cookieStore = (BasicCookieStore) context.getCookieStore();
我该怎么做?
HttpClientBuilder client = HttpClientBuilder.create();
HttpResponse response = null;
HttpClientContext context = HttpClientContext.create();
BasicCookieStore cookieStore = new BasicCookieStore();
client.setDefaultCookieStore(cookieStore);
response = client.build().execute(get);
cookieStore = context.getCookieStore();
它告诉我:无法将 CookieStore 转换为 BasicCookieStore。我不能使用 CookieStore 接口而不是 BasicCookieStore,因为在我的另一个 类 中显示 "Interfaces can't be instantiated".
我认为选角会对你有所帮助。
BasicCookieStore cookieStore = (BasicCookieStore) context.getCookieStore();