struts2 下载文件,下载弹出框,文件名中文乱码
2012-05-25 19:31
615 查看
Struts2 实现文件下载时,下载对话框出现中文乱码情况
解决方案:
public void setFileName(String fileName) throws UnsupportedEncodingException { this.fileName = new String(fileName.getBytes("utf-8"), "ISO8859-1"); }需要注意的是,文件名的编码必须与浏览器的一致。
后续:在IE环境下,下载对话框仍会出现中文乱码情况。解决方案:
public String getFileName()throws UnsupportedEncodingException { return new String(fileName.getBytes("utf-8"), "ISO8859-1"); } public void setFileName(String fileName) throws UnsupportedEncodingException { this.fileName=URLEncoder.encode(fileName, "UTF-8"); if (fileName.length() > 150) { String guessCharset ="utf-8"; /*根据request的locale 得出可能的编码,中文操作系统通常是gb2312*/ this.fileName = new String(fileName.getBytes(guessCharset), "IsSO8859-1"); } //this.fileName = fileName; }
但是firefox环境下,又不行 。。 怎样兼顾ie、firefox呢? 继续跟进
相关文章推荐
- 解决Struts2文件下载文件名中文乱码
- Struts2文件下载文件名中文出现乱码解决办法
- struts2 Annotation 实现文件下载功能 文件名中文乱码问题
- 解决struts2下载文件时中文文件名乱码
- Struts2文件下载文件名中文出现乱码解决办法
- struts2 Annotation 实现文件下载功能 文件名中文乱码问题
- Struts2 .apk 文件下载及解决中文文件名乱码问题(转)
- Struts2 文件下载中文文件名乱码问题
- Struts2 .apk 文件下载及解决中文文件名乱码问题(转)
- struts2 文件下载文件名中文乱码及变成空格问题
- java下载文件中文文件名乱码问题(ie,谷歌,火狐)
- Struts2 文件上传下载 含下载时中文乱码
- 解决php输出文件下载时文件名含中文时出现乱码
- struts2解决文件上传下载中文乱码问题
- struts2解决下载中文文件乱码问题
- java web应用文件下载(包括中文文件名乱码处理
- Java strtus2文件下载不同浏览器文件名中文乱码处理
- jsp实现文件下载与中文文件名乱码问题解决
- HTTP 文件下载时中文文件名乱码问题处理
- struts2下载文件名设置和中文下载时乱码如何设置