Java exports csv file through header with garbled characters
巴扎黑
巴扎黑 2017-05-17 09:58:38
0
2
663

java Export csv file with garbled characters through header

try{
               
                context.response().putHeader("Content-type", "text/csv; charset=UTF-8")
                        .putHeader("Content-Disposition", "attachment;filename="+csv_name+".csv;charset=utf-8")
                        .putHeader("write","\ufeff")
                        .end(string);

            }catch (Exception e){
                e.printStackTrace();
            }
巴扎黑
巴扎黑

reply all(2)
Peter_Zhu

utf8 csv files need to have BOM header
Reference link http://blog.csdn.net/youzhoul...

迷茫

Changing UTF-8 to GBK should eliminate garbled characters. CSV is a bit tricky

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!