1. <nobr id="easjo"><address id="easjo"></address></nobr>

      <track id="easjo"><source id="easjo"></source></track>
      1. 
        

      2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
      3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>
          貴州做網站公司
          貴州做網站公司~專業!靠譜!
          10年網站模板開發經驗,熟悉國內外開源網站程序,包括DEDECMS,WordPress,ZBlog,Discuz! 等網站程序,可為您提供網站建設,網站克隆,仿站,網頁設計,網站制作,網站推廣優化等服務。我們專注高端營銷型網站,企業官網,集團官網,自適應網站,手機網站,網絡營銷,網站優化,網站服務器環境搭建以及托管運維等。為客戶提供一站式網站解決方案?。?!

          Content-Disposition

          來源:互聯網轉載 時間:2024-01-29 08:21:49

          Content-Disposition

          文件下載響應頭的設置

          content-type?指示響應內容的格式

          content-disposition?指示如何處理響應內容。

          一般有兩種方式:

          • inline:直接在頁面顯示
          • attchment:以附件形式下載
          /**
          * 設置強制下載
          * @param fileName
          * @param response
          */
          @RequestMapping("/downOpen")
          public void downOpen(@RequestParam("fileName") String fileName,HttpServletResponse response){
          String fix = fileName.substring(fileName.lastIndexOf("."), fileName.length());
          response.setHeader("Content-Disposition", "attachment;filename=" + System.currentTimeMillis()+fix);
          response.setContentType("application/force-download");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.downloadOpen(fileName,response);
          }

          /**
          * 設置Content-Disposition :inline 無效直接下載,不打開
          * @param fileName
          * @param response
          */
          @RequestMapping("/forceDownInline")
          public void forceDownInline(@RequestParam("fileName") String fileName,HttpServletResponse response){
          String fix = fileName.substring(fileName.lastIndexOf("."), fileName.length());
          response.setHeader("Content-Disposition", "inline;filename=" + System.currentTimeMillis()+fix);
          response.setContentType("application/force-download");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.downloadOpen(fileName,response);
          }

          /**
          * 不設置 Content-Disposition 在頁面顯示
          * @param url
          * @param response
          */
          @RequestMapping("/urlOpen/{url}")
          public void urlOpen(@PathVariable("url") String url, HttpServletResponse response){
          response.setContentType("image/png");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.urlOpen(url,response);
          }
          /**
          * inline:直接在頁面顯示
          * @param url
          * @param response
          */
          @RequestMapping("/urlOpenInline/{url}")
          public void urlOpenInline(@PathVariable("url") String url, HttpServletResponse response){
          response.setHeader("Content-Disposition", "inline;filename=" + System.currentTimeMillis()+".png");
          response.setContentType("image/png");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.urlOpen(url,response);
          }

          /**
          * 附件形式下載,不打開
          * @param url
          * @param response
          */
          @RequestMapping("/urlDownAttachment/{url}")
          public void urlDownAttachment(@PathVariable("url") String url, HttpServletResponse response){
          response.setHeader("Content-Disposition", "attachment;filename=" + System.currentTimeMillis()+".png");
          response.setContentType("image/png");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.urlOpen(url,response);
          }

          /**
          * attachment:以附件形式下載,不打開
          * @param url
          * @param response
          */
          @RequestMapping("/downAttachment/{url}")
          public void downAttachment(@PathVariable("url") String url, HttpServletResponse response){
          response.setHeader("Content-Disposition", "attachment;filename=" + System.currentTimeMillis()+".png");
          response.setContentType("application/octet-stream");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.urlOpen(url,response);
          }

          /**
          * 設置Content-Disposition :inline 無效 直接下載 不打開
          * @param url
          * @param response
          */
          @RequestMapping("/streamInline/{url}")
          public void streamInline(@PathVariable("url") String url, HttpServletResponse response){
          response.setHeader("Content-Disposition", "inline;filename=" + System.currentTimeMillis()+".png");
          response.setContentType("application/octet-stream");
          response.setCharacterEncoding("UTF-8");
          FtpUtil.urlOpen(url,response);
          }
          ?

          以上這幾種設置方式,在<img>?標簽中都會展示出圖片,不同的是在瀏覽器訪問,

          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為二進制流數據-->
          <img alt="downOpen" src="http://localhost:8080/ftp/downOpen?fileName=1677072114406.jpeg"/>
          </p>
          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為圖片本圖-->
          <img alt="urlOpen" src="http://localhost:8080/ftp/urlOpen/1677072114406.jpeg"/>
          </p>
          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為圖片本圖-->
          <img alt="urlOpenInline" src="http://localhost:8080/ftp/urlOpenInline/1677072114406.jpeg"/>
          </p>
          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為圖片本圖-->
          <img alt="downAttachment" src="http://localhost:8080/ftp/downAttachment/1677072114406.jpeg"/>
          </p>
          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為圖片本圖-->
          <img alt="urlDownAttachment" src="http://localhost:8080/ftp/urlDownAttachment/1677072114406.jpeg"/>
          </p>
          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為圖片本圖-->
          <img alt="streamInline" src="http://localhost:8080/ftp/streamInline/1677072114406.jpeg"/>
          </p>
          <p style="width: 100px;height: 100px;">
          <!--顯示有效,預覽為二進制流數據-->
          <img alt="streamInline" src="http://localhost:8080/ftp/forceDownInline?fileName=1677072114406.jpeg"/>
          </p>

          在<img>標簽中,預覽會有不同

          設置

          response.setContentType("application/octet-stream");?預覽為二進制流數據

          其他設置預覽為圖片

          在瀏覽器訪問url時設置

          Content-Disposition :attachment 會下載,不打開
          Content-Disposition :inline 不下載,直接打開

          網絡推廣與網站優化公司(網絡優化與推廣專家)作為數字營銷領域的核心服務提供方,其價值在于通過技術手段與策略規劃幫助企業提升線上曝光度、用戶轉化率及品牌影響力。這...

          在當今數字化時代,公司網站已成為企業展示形象、傳遞信息和開展業務的重要平臺。然而,對于許多公司來說,網站建設的價格是一個關鍵考量因素。本文將圍繞“公司網站建設價...

          在當今的數字化時代,企業網站已成為企業展示形象、吸引客戶和開展業務的重要平臺。然而,對于許多中小企業來說,高昂的網站建設費用可能會成為其發展的瓶頸。幸運的是,隨...

          滔搏運動和專賣店的區別?Taub體育的銷售有多個一線運動品牌,屬于一站式采購;專賣店是某個品牌獨家擁有的店鋪。在購物的選擇上不同。塔爾博特指的是百麗國際的體育業務線,在有9家分公司,總部在上海。上海塔爾博特體育事業總部負責對全國9家分公司的服務、支持、指導和監督。百麗集團已成為眾多國際運動品牌在的最大經銷商,供貨渠道和質量有保證。京東為啥有兩個滔搏官方店?因為一個是旗艦店,一個是自營店。在JD.C...

          食鹽的保質期一般是多長時間?就食鹽本身而言,沒有保質期,食用鹽可以免于標準保質期。鹽的主要成分是氯化鈉,化學性質穩定,不易變質。醬油是有保質期的。食用鹽的保質期可以免除。如果食鹽中添加了鈣、鐵、鋅、硒等微量元素的鹽,應標注保質期。就鹽本身而言,沒有保質期,只要放在防潮避光的地方就可以了。這是因為鹽的主要成分是氯化鈉,氯化鈉化學性質穩定,一袋300-500克的鹽,幾個月后就會被人吃掉。鹽保質期是多久...

          macoslion怎么重裝?獅子重裝恢復高清Oslion包括一組內置的恢復HD實用程序。重啟Mac,按住Command和R鍵(Command-R)直到出現蘋果圖標,這表示Mac正在啟動。HD啟動后,您應該會看到帶有Mac OS X菜單欄和#34Mac OS X實用程序#34應用程序窗口的桌面。注:如果看到登錄窗口或者自己的桌面和圖標,可能是因為沒有早點按Command-R。請重新啟動計算機...

          TOP
          国产初高中生视频在线观看|亚洲一区中文|久久亚洲欧美国产精品|黄色网站入口免费进人
          1. <nobr id="easjo"><address id="easjo"></address></nobr>

              <track id="easjo"><source id="easjo"></source></track>
              1. 
                

              2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
              3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>