zoukankan      html  css  js  c++  java
  • java 返回图片到页面

    @RequestMapping(value = "/image/get")
        public void getImage(HttpServletRequest request,HttpServletResponse response) {
            FileInputStream fis = null;
            response.setContentType("image/gif");
            try {
                OutputStream out = response.getOutputStream();
                File file = new File("D:"+File.separator+"timg.jpg");
                fis = new FileInputStream(file);
                byte[] b = new byte[fis.available()];
                fis.read(b);
                out.write(b);
                out.flush();
            } catch (Exception e) {
                 e.printStackTrace();
            } finally {
                if (fis != null) {
                    try {
                       fis.close();
                    } catch (IOException e) {
                    e.printStackTrace();
                }   
                  }
            }
        }
  • 相关阅读:
    HDU
    HDU
    CodeForces
    HDU——2955 Robberies (0-1背包)
    南京区域赛之后
    算法作业三-哈夫曼编码
    HDU
    POJ 1220 NUMBER BASE CONVERSION(进制转换,大数)
    HDU 1535 Invitation Cards(最短路)
    HDU 3572 Task Schedule(网络流+当前弧优化)
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7054719.html
Copyright © 2011-2022 走看看