我是使用Spring的新手。我对代码的工作尝试使用restTemplate.getForObject没有通过RestTemplate.getForObject传递标头
客户端传递标题:
String userServiceUrl = "http://localhost:8080/SampleRest/api/user/";
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", UUID.randomUUID().toString());
restTemplate.getForObject(userServiceUrl + "{id}",User.class,HttpMethod.GET,headers) ;
但是对服务器的请求头“认证”没有全部通过。没有标头 “身份验证”
requestHeaders.get("Authorization").get(0) //yields null exception
我不能使用restTemplate.exchange
我究竟做错了什么?
帮助将不胜感激
它应该不是requestHeaders.get(“Authentication”)。get(0)? – achingfingers 2014-09-04 14:28:38
为什么?我用“授权”设置了一个标题,我希望在服务器端获得相同的标题 – igx 2014-09-04 14:52:33