spring android如何设置超时时间呢?

lzk_ys 发布于 2014/04/01 17:50
阅读 643
收藏 0
请问使用spring android从网络获取数据时,如何设置超时时间呢?

            List<CommCatetory> cateList = null;

            HttpHeaders requestHeaders = new HttpHeaders();
            requestHeaders.setAccept(Collections.singletonList(new MediaType("application","json")));
            HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
            RestTemplate restTemplate = new RestTemplate();
            ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
            String json = new String(responseEntity.getBody().getBytes("utf_8"));
            Gson gson = new Gson();
            Type type = new TypeToken<List<CommCatetory>>(){}.getType();
            cateList = gson.fromJson(json, type);
加载中
返回顶部
顶部