ResponseEntity<String> response = restTemplate.getForEntity(url,String.class); String body = response.getBody(); checkSend(body); public JSONObject checkSend(String data){ JSONObject jsonData = JSONObject.parse(data); if(jsonData == null || jsonData.isEmpty()){ throw new BaseException(StatusCode.SEND_FAILED,"推送关联方失败"); } String resultCode = jsonData.getString("resultCode"); if(StringUtils.isEmpty(resultCode) || FAILED_CODE.equals(resultCode)){ throw new BaseException(StatusCode.SEND_FAILED,"推送关联方失败"); } JSONObject jsonResult = jsonData.getJSONObject(); if(jsonResult == null || jsonResult.isEmpty()){ throw new BaseException(StatusCode.SEND_FAILED,"推送关联方失败"); } } public class BaseException extends RuntimeException{ private String code; public BaseException(){} public BaseException(String message){ super(message); } public BaseException(String code,String message){ super(message); this.code = code; } }