admin 管理员组

文章数量: 887019

String userAgent = request.getHeader("user-agent").toLowerCase();
          if (userAgent.contains("msie") || userAgent.contains("like gecko") ) {  
                  // win10 ie edge 浏览器 和其他系统的ie  
              fileName =  URLEncoder.encode(fileName,"UTF-8");
              fileName = fileName.replaceAll("\\+", "%20").replaceAll( "\\(","%28").replaceAll( "\\)","%29").replaceAll( ";","%3B").replaceAll( "@","%40").replaceAll( "\\#","%23").replaceAll( "\\&","%26").replaceAll( "\\,","%2C");
          } else {  
                  // fe  
              fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1");  
          }  
              response.addHeader("Content-Disposition", "attachment;filename="+ fileName);

文件名转换的方法要放对地方,放在返回文件下载信息里。

转载于:https://wwwblogs/moonlignt/p/9228861.html

本文标签: 乱码 空格 中文 浏览器 文件