使用AsyncRestTemplate 来实现异步的回调
1、回调就是是啥
最常见的就是Ajax
2、使用举例
@RequestMapping("/authForPerson")
public void authForPerson(){
JSONObject queryData = new JSONObject();
queryData.put("sfzh","330622196603172237");
HttpEntity httpEntity = new HttpEntity(queryData);
ListenableFuture<ResponseEntity<String>> entity = staticAsyncRestTemplate.postForEntity("http://apaas.wfsczjdsjpt-tes.local/weifang/api/zb/cjrInfo", httpEntity, String.class);
entity.addCallback(new ListenableFutureCallback<ResponseEntity<String>>() {
@Override
public void onFailure(Throwable throwable) {
System.out.println("faile");
}
@Override
public void onSuccess(ResponseEntity<String> stringResponseEntity) {
System.out.println("success");
}
});
};
3、代码链接
代码链接见文件里面的压缩包。
浙公网安备 33010602011771号