码迷,mamicode.com
首页 > 其他好文 > 详细

setCookie

时间:2019-06-05 19:32:02      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:linked   ppi   remember   pen   http   sse   lin   abc   let   

@Autowired
private RestTtestRestTemplate

@RtopControllerAnnotation
@ResponseBody
@RequestMapping(value = "/test.json", method = RequestMethod.GET)
public RtopHttpResult test(HttpServletRequest request, HttpServletResponse response) {
RestTemplate restTtestRestTemplate= new RestTemplate();
MultiValueMap<String, String> mParams = new LinkedMultiValueMap<String, String>();
mParams.add("loginName", "admin");
mParams.add("pwd", "Abc12345");
mParams.add("remember", "true");
mParams.add("LOGIN_TYPE", "bucSsoLoginHandler");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<MultiValueMap<String, String>> httpRequest = new HttpEntity<MultiValueMap<String, String>>(mParams, headers);
ResponseEntity<Object> responseEntity = restTtestRestTemplate.postForEntity( "http://lcoalhost:8080/iam/doLogin.json", httpRequest, Object.class);
Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
List<String> setCookie = responseEntity.getHeaders().get("Set-Cookie");
if (setCookie!= null){
String cookie = setCookie.toString().replace("[", "").replace("]", "");
response.setHeader("Set-Cookie",cookie);
}
return Success(null);
}

setCookie

标签:linked   ppi   remember   pen   http   sse   lin   abc   let   

原文地址:https://www.cnblogs.com/wwqwwq/p/10981332.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!