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

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

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;
    }

  

 

上一篇:Android Framework实战视频--BootAnimation的启动源码分析(Android8.1)


下一篇:Android之SurfaceFlinger服务