@Component public class RestTemplateUtil { @Autowired RestTemplate restTemplate; public Map post(String url, String method, String params, String token) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.add("service",method); headers.add("authorization",token); HttpEntity<String> request = new HttpEntity<String>(params, headers); Map returnJson = restTemplate.postForObject(url, request, Map.class); return returnJson; } }
restTemplate携带token进行远程调用配置类
最新推荐文章于 2023-10-10 16:48:22 发布