1
不能使用多個catch嗎?一是抓使用了RestClientException
和第二次使用HttpStatusCodeException
錯誤:(229,12)java:異常org.springframework.web.client.HttpStatusCodeException已被捕獲
try {
ResponseEntity<Stdo> responseEntity = restTemplate.exchange(theUrl, HttpMethod.POST, entity, Stdo.class);
}catch (RestClientException ex) {
if (ex.toString().contains("Connection timed out")) {
}
}catch(HttpStatusCodeException ex)
{
// get http status code
}
}
錯誤
Error:(229, 12) java: exception org.springframework.web.client.HttpStatusCodeException has already been caught