我正在POST服务器请求,但是当我面对
时客户端org.springframework.web.client.HttpClientErrorException:400 不好请求
调用onRequestSuccess
而不是onRequestFailure
public String loadDataFromNetwork() {
String url = "myurl";
HttpHeaders header = new HttpHeaders();
header.setContentType(new MediaType("application", "json"));
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put(constants.TAG_ORDER_ID, bOrderID);
RestTemplate restTemplate = new RestTemplate(true);
restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());
HttpEntity<?> httpEntity = new HttpEntity<Object>( jsonObject.toString() , header);
ResponseEntity r = restTemplate.exchange(url, HttpMethod.POST, httpEntity, getResultType());
return r.toString();
}
catch (HttpClientErrorException e){
return String.valueOf(e);
}
catch (JSONException e){
return String.valueOf(e);
}
}
答案 0 :(得分:0)
只要您正在捕捉FFI:Def-call-in
内的异常而不是重新抛出它们,RoboSpice认为没有发生任何异常。传播错误的唯一方法是从loadDataFromNetwork()
中抛出错误,然后通过loadDataFromNetwork()
回复。