关于java模拟登录获取Cookie时经历的坑
springboot 引入jar包版本
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
通过httpclient来模拟登录
代码部分
String loginUrl = "需要调用的接口";
//用来存储cookie的值
CookieStore cookieStore = new BasicCookieStore();
//创建httpClient
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
try {
//根据接口需要的入参添加相对应的数值
Map<String,String> map = Maps.newHashMap();
map.put("userCode","用户名");
map.put("password"