resttemplate getForObject map responsetype

后端 未结 6 1739
囚心锁ツ
囚心锁ツ 2021-02-06 23:58

Update 02/05/2018 (about 4 years later)...I tested this again as people have been upvoting my question/answer and Sotirios Delimanolis is correct that I should not h

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 00:32

    @GetMapping(value = "getSunny/{userId}")
        public Map getSunny(@PathVariable int sunnyId) {
            
            Map newObj = new HashMap();
            final String url = "http://localhost:8085/Sunny/getSunny/{sunnyId}";
            RestTemplate restTemplate = new RestTemplate();
            newObj = restTemplate.getForObject(url, Map.class, sunnyId);
            return newObj;
    
        }
    

    It is working for me ...

提交回复
热议问题