文件下载时,文件名乱码问题

文件下载时,解决不同浏览器文件名乱码问题

public static String encodeFileName(HttpServletRequest request, String pFileName) { String userAgent = request.getHeader("USER-AGENT"); try { if (userAgent.contains("msie") || userAgent.contains("like gecko")) { pFileName = URLEncoder.encode(pFileName, "utf-8"); } else { pFileName = new String(pFileName.getBytes("utf-8"), "iso8859-1"); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return pFileName; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgdsgw.html