通过URL接受图片并展示

【通过URL接受图片并展示】通过RestTemplate访问指定的URL地址接收数据。将图片在界面展示出来。
PictureController.java

package cn.cw.controller; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.ModelAndView; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import cn.cw.util.DateUtil; @Controller @RequestMapping("/picture") public class PictureController {@Value("${cma.history.pictureUrl}") private String url; @RequestMapping("/index.do") @ResponseBody public ModelAndView index() {return new ModelAndView("biz/picture"); }@RequestMapping("/getPicture.do") @ResponseBody public String getPicture(HttpServletRequest request) {String id = request.getParameter("terminalId"); String begin = request.getParameter("begin"); String end = request.getParameter("end"); JSONObject resultJson = new JSONObject(); List data= https://www.it610.com/article/new ArrayList(); RestTemplate restTemplate = new RestTemplate(); MultiValueMap requestEntity = new LinkedMultiValueMap<>(); requestEntity.add("id", id); requestEntity.add("begin", begin); requestEntity.add("end", end); String response = restTemplate.postForObject(url, requestEntity, String.class); JSONArray resArr = JSON.parseArray(response); if(resArr.size()>0){ for(int i=0; i
picture.html
历史图片查询 - 锐客网
终端ID: 开始时间: 结束时间:

    推荐阅读