小编Ali*_*yon的帖子

Spring RestTemplate重定向302

我正在尝试使用spring rest模板来发布登录请求.

RestTemplate restTemplate = new RestTemplate();

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

LinkedMultiValueMap<String, Object> mvm = new LinkedMultiValueMap<String, Object>();
mvm.add("LoginForm_Login", "login");
mvm.add("LoginForm_Password", "password");

ResponseEntity<String> result = restTemplate.exchange(uriDWLogin, HttpMethod.POST, requestEntity, String.class);
Run Code Online (Sandbox Code Playgroud)

我的ResponseEntity状态是302,我想跟随此请求获取正文响应,因为我没有获得此请求的正文.

18:59:59.170 MAIN [http-nio-8080-exec-83] DEBUG c.d.s.c.DemandwareCtlr - loginToSandbox - StatusResponse - 302
18:59:59.170 MAIN [http-nio-8080-exec-83] DEBUG c.d.s.c.DemandwareCtlr - loginToSandbox - BodyResponse - 
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能解决这个问题?

rest redirect spring response http-status-code-302

8
推荐指数
1
解决办法
2万
查看次数

Spring Rest RestTemplate

我正在尝试使用spring rest模板来发布登录请求.

RestTemplate restTemplate = new RestTemplate();

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

LinkedMultiValueMap<String, Object> mvm = new LinkedMultiValueMap<String, Object>();
mvm.add("LoginForm_Login", "login");
mvm.add("LoginForm_Password", "password");

ResponseEntity<String> result = restTemplate.exchange(uriDWLogin, HttpMethod.POST, requestEntity, String.class);
Run Code Online (Sandbox Code Playgroud)

一切顺利,但当我尝试发送第二个请求时,它会生成错误说:

业务经理在15分钟后关闭您的会话

我该怎么做才能解决这个问题?

rest spring spring-mvc resttemplate

1
推荐指数
1
解决办法
1万
查看次数