相关疑难解决方法(0)

使用RestTemplate设置安全cookie

我试图使用RestTemplate和Jackson json转换器调用Restful JSON服务.现在,为了调用服务,我需要传递一个安全cookie.我可以通过使用URLConnection来实现这一点(参见下面的代码)

URL url= new URL("https://XXXXXXXX");

URLConnection yc = url.openConnection();
yc.setRequestProperty("SecurityCookie", ssocookie.getValue());</code>
Run Code Online (Sandbox Code Playgroud)

什么是RestTemplate中的并行?这是我用来使用RestTemplate调用Restful Service的代码片段:

RestTemplate rest = new RestTemplate();  
InputBean input = new InputBean();  
input.setResource("SampleResource");  
HttpEntity<InputBean > entity = new HttpEntity<InputBean>(input);  
ResponseEntity<OutputBean> response1 = rest.postForEntity(
    "https://XXXXXXXXX", 
    entity, OutputBean.class);</code>
Run Code Online (Sandbox Code Playgroud)

在使用RestTemplate调用服务时,我无法弄清楚如何传递安全cookie.对此的任何帮助都会很棒.

java cookies spring resttemplate

9
推荐指数
2
解决办法
3万
查看次数

标签 统计

cookies ×1

java ×1

resttemplate ×1

spring ×1