java下载乱码问题 fileName= new String(fileName.getBytes("GBK"),"8859_1"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 fileName= new String(fileName.getBytes("UTF-8"),"8859_1");可以解决IE中的问题 但是火狐中的问题还是解决不了 解决了:先在页面做下判断,判断是什么浏览器,然后传一个参数到servlet,进行用不同的编码方式:火狐的:response.addHeader("Content-Disposition", "attachment;filename="+ new String(fileName.getBytes("GB2312"),"ISO8859-1"));IE:response.addHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(fileName, "UTF-8")); 及其他 String header = ServletActionContext.getRequest().getHeader( "User-Agent"); // 如果是火狐 if (header.contains("Firefox")) { filedisplay = new String(filedisplay.getBytes(), "iso8859-1"); } else { // IE要用URL编码格式 filedisplay = URLEncoder.encode(filedisplay, "UTF-8"); } 嵌入式测试,需要学哪些硬件知识? list和数组哪个存储空间更大? 动态二级联动下拉菜单 求教关于struts中formbean的问题(请高手指点一下,不胜感谢) portlet连接数据库??? 别人机子上的struts项目拷贝到我的机子上运行调试不了 Tomcat 问题 apache Logger 编译问题请教(急!) ????奇怪的编码转换问题!!!! struts中加入javascript的问题! 面试归来,发一个逻辑题,求解 菜鸟求助,已知wsdl文件,怎么调用接口???
可以解决IE中的问题 但是火狐中的问题还是解决不了
先在页面做下判断,判断是什么浏览器,然后传一个参数到servlet,进行用不同的编码方式:
火狐的:
response.addHeader("Content-Disposition", "attachment;filename="+ new String(fileName.getBytes("GB2312"),"ISO8859-1"));
IE:
response.addHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(fileName, "UTF-8"));
及其他
"User-Agent");
// 如果是火狐
if (header.contains("Firefox")) {
filedisplay = new String(filedisplay.getBytes(), "iso8859-1");
} else {
// IE要用URL编码格式
filedisplay = URLEncoder.encode(filedisplay, "UTF-8");
}