我可以在浏览器中读取此URL,但不能使用javascript
https://www.planete-sorties.net/api/api/ressources/types
此服务生成如下:
@RequestMapping(value = URL_RESOURCES_TYPES, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getTypes() {
String serviceResult = paramService.getTypes().toString();
return ResponseEntity.ok().body(serviceResult);
}
实际上,我正在构建一个react原生应用,错误是
[类型错误:网络请求失败]
我也试着在这里读取网址https://reqbin.com/,有一个错误。
在Java中我可以这样读
UriComponentsBuilder uriBuilder =
UriComponentsBuilder.fromHttpUrl(appendHost(URL_RESOURCES_TYPES));
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(null, getHeaders());
RestTemplate restTemplate = restTemplateConfig.restTemplate();
ResponseEntity<String> serviceResultRE = restTemplate.exchange(uriBuilder.toUriString(), HttpMethod.GET, requestEntity, String.class);
1条答案
按热度按时间7cjasjjr1#
代替
用途