使用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、代码链接

代码链接见文件里面的压缩包。

 

上一篇:vmstat命令


下一篇:[C++] C++标准中定义的实体(entity)/ 声明 / 定义