校验判断接口的status_code(HTTP状态码)以及返回信息;
接口地址为:https://easy-mock.com/mock/5c0e4602dbf7436640a68d74/simple/response
String url = "https://easy-mock.com/mock/5c0e4602dbf7436640a68d74/simple/response";
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
LOGGER.info("ResponseEntity StatusCode={}", responseEntity.getStatusCode());
LOGGER.info("ResponseEntity={}", responseEntity);
给个案例,参考哈:
$.ajax({
url: "xxxx",
type: "POST",
data: {
},
dataType:"xxx",
success: function(xml, textStatus, xhr) {
console.log(arguments);
console.log(xhr.status);
},
complete: function(xhr, textStatus) {
console.log(xhr.status);
}
});
status就是响应的状态码。