嗨,当我打电话给休息网络服务时,我收到错误404
网络服务方法是:
@RequestMapping(value = "/natlist", produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<List<Nacionalidades>> getnatlist()
{
List<Nacionalidades> nacionalidadesList = new ArrayList<>();
.....
return new ResponseEntity<>(nacionalidadesList, HttpStatus.OK);
}
对Web服务的调用
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(HttpClients.createDefault());
RestTemplate restTemplate = new RestTemplate(requestFactory);
try
{
ResponseEntity<Nacionalidades[]> responseEntity = restTemplate.getForEntity(url, Nacionalidades[].class);
HttpStatus statusCode = responseEntity.getStatusCode();
if (statusCode == HttpStatus.OK)
{
Nacionalidades[] natArr = responseEntity.getBody();
....
}
}
网络服务方法是:
enter code here
答案 0 :(得分:0)
你不应该使用路径参数而不是值吗?你试过这个吗?
@RequestMapping(path = "/natlist", produces = "application/json", method = RequestMethod.GET)