浏览器文件导出、下载(文件名)乱码解决方法

来源:互联网 发布:淘宝网店怎么找回 编辑:程序博客网 时间:2024/04/29 18:30
    /**     *      * 导出文件名称     *      */    private String downloadFileName;    public String getDownloadFileName() {        return downloadFileName;    }    public void setDownloadFileName(String downloadFileName) {        HttpServletRequest request = ServletActionContext.getRequest();           String Agent = request.getHeader("User-Agent");        if (null != Agent) {                Agent = Agent.toLowerCase();                //火狐浏览器                if (Agent.indexOf("firefox") != -1) {                        downloadFileName = new String(downloadFileName.getBytes(), "ISO-8859-1");                } else {                        downloadFileName = new String(downloadFileName.getBytes(), "UTF-8");                }        } else {                downloadFileName = new String(downloadFileName.getBytes(), "UTF-8");        }        this.downloadFileName = downloadFileName;    }