乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      兼容各瀏覽器的文件下載時中文名稱亂碼的解決方案

       ThinkTank_引擎 2016-01-27
      Java代碼  收藏代碼
      1. public class DownloadServlet extends HttpServlet {  
      2.     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
      3.         // codes..  
      4.         String name = "中文名 帶空格 的測試文件.txt";  
      5.         String userAgent = request.getHeader("User-Agent");  
      6.         byte[] bytes = userAgent.contains("MSIE") ? name.getBytes() : name.getBytes("UTF-8"); // name.getBytes("UTF-8")處理safari的亂碼問題  
      7.         name = new String(bytes, "ISO-8859-1"); // 各瀏覽器基本都支持ISO編碼  
      8.         response.setHeader("Content-disposition", String.format("attachment; filename=\"%s\"", name)); // 文件名外的雙引號處理firefox的空格截斷問題  
      9.         // codes..  
      10.     }  
      11. }  


      這段代碼處理了文件下載時不同瀏覽器解析中文文件名所出現(xiàn)的亂碼問題和firefox的空格截斷問題,在IE9, chrome, opera, safari, firefox下均測試通過。

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多