java下载csv文件,中文标题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@RequestMapping(value = "/export.do")
public void exportpushuserByareacode(HttpServletRequest req, HttpServletResponse rsp)
            throws Exception {
         
        List list = .....;     
        String name="导出的文件.csv";
        name = new String(name.getBytes("GBK"), "ISO8859-1");   
 
        rsp.setContentType("application/csv;charset=GBK");
        rsp.addHeader("Content-Disposition", "attachment;filename="+name);
        PrintWriter out = rsp.getWriter();
         
        String header = "name\r\n";
        out.write(header);
         
        for (Object o : list) {
            String str = o.toString().concat("\r\n");
            out.print(str);
            out.flush();
        }
        return;
    }      
 
 java 后台下载文件,文件名字为中文名字。

java下载csv文件,中文标题,布布扣,bubuko.com

java下载csv文件,中文标题

上一篇:wow.js


下一篇:Java8简明教程(转载)