RestTemplate代码:
final HttpEntity<String> entity = new HttpEntity<String>(headers);
ResponseEntity<String> quote = restTemplate.exchange(
"http://localhost:8080/groups/HOLDEN_REGION",HttpMethod.GET, entity , String.class);
控制器代码:
@RestController public class GroupController {
@RequestMapping(value="/groups/{groupTypeName}", method= RequestMethod.GET)
public Set<Group> getGroups(@ApiParam(value = "groupTypeName", required = true) @PathVariable("groupTypeName") String groupTypeName) {
return groupService.getGroupsForGroupTypeName(groupTypeName);
}
}
当我使用curl和浏览器点击相同的网址时,它没有任何问题。但是当我使用spring resttemplate时,我收到404错误。我试图设置标题和所有,但仍然没有运气。任何帮助将不胜感激。