对于接口不熟悉,源自于一次项目需要,体会到学习的重要性,好好学习,天天向上!
//1.发送请求
String url="http://...";
String resultString = HttpClientUtil.doPost(url);
//2. 解析返回值
ResultEntity resultEntity = jm.fromJson(resultString, ResultEntity.class);
//3.获取数据
Map data = (Map)resultEntity.getData();
Map todayWeather = (Map)data.get("todayWeather");
model.addAttribute("todayWeather", todayWeather);
前端获取数据:
<div class="weather">天气:
<c:choose>
<c:when test="${todayWeather.tempdescday == todayWeather.tempdescnight}">
${todayWeather.tempdescday}
</c:when>
<c:otherwise>
${todayWeather.tempdescday }转${todayWeather.tempdescnight}
</c:otherwise>
</c:choose>
   ${todayWeather.temphigh}℃~${todayWeather.templow}℃</div>
</div>