zoukankan      html  css  js  c++  java
  • java 下载文件,兼容Firefox 36.0.1/IE8/Chrome 40.0.2214.93 m/360 7.1.1.322等浏览器

        public void download(HttpServletRequest request, HttpServletResponse response) throws Exception {
                request.setCharacterEncoding("UTF-8");
                String filePath = request.getParameter("filePath");
                String fileName = request.getParameter("fileName");
                if (StringUtils.isNotBlank(fileName)) {
                    response.setContentType("application/force-download");// 应用程序强制下载
                String userAgent = request.getHeader("User-Agent");
                byte[] bytes = userAgent.contains("MSIE") ? fileName.getBytes() : fileName.getBytes("UTF-8");
                fileName = new String(bytes, "ISO-8859-1");
                response.setHeader("Content-Disposition", String.format("attachment; filename="%s"", fileName));
                }
            download(filePath, response.getOutputStream());
        }
    

      

  • 相关阅读:
    什么是透视图?
    Eclipse 视图
    Eclipse 菜单
    Eclipse 窗口说明
    Eclipse 修改字符集
    Eclipse 安装(Oxygen版本)
    Eclipse 教程
    jQuery 教程
    就表单验证说用户体验
    需要配置执行path?no
  • 原文地址:https://www.cnblogs.com/jiehanshi/p/12390013.html
Copyright © 2011-2022 走看看