Java Web开发下载文件,文件名中文乱码解决方案。

fileName  =  new  String( fileName .getBytes( "UTF-8" ),  "ISO-8859-1" );

这种方式在IE下和Firefox下均可以得到中文文件名的文件。但如果文件名中带有空格,Firefox会从空格处截断文件名,需要在编码之前将文件名中的空格替换成下划线之类的可见字符。

fileName  =  new  String( fileName .replace( " " "_" ).getBytes( "UTF-8" ),  "ISO-8859-1" );
转载: https://blog.csdn.net/mayuanxiaonong/article/details/21230547

猜你喜欢

转载自blog.csdn.net/en_joker/article/details/80410889