Excel 중국어 파일 이름 다운로드


public static String encodeFileName(String fileName, HttpServletRequest request) {
        String agent = request.getHeader("USER-AGENT");
        try {
            if ((agent != null) && (-1 != agent.indexOf("MSIE"))) {
                String newFileName = URLEncoder.encode(fileName, "UTF-8");
                newFileName = StringUtils.replace(newFileName, "+", "%20");
                if (newFileName.length() > 150) {
                    newFileName = new String(fileName.getBytes("GB2312"), "ISO8859-1");
                    newFileName = StringUtils.replace(newFileName, " ", "%20");
                }
                return newFileName;
            }
            if ((agent != null) && (-1 != agent.indexOf("Mozilla"))) {
                // return MimeUtility.encodeText(fileName, "UTF-8", "B");
                return URLEncoder.encode(fileName, "UTF-8");
            }
            return fileName;
        } catch (Exception ex) {
            return fileName;
        }
    }


String fileName = " ";
fileName = encodeFileName(fileName, request);
response.setContentType("application/vnd.ms-excel");     
response.setHeader("Content-disposition", "attachment;filename*=utf-8'zh_cn'" + fileName + ".xls");  



좋은 웹페이지 즐겨찾기