@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 后台下载文件,文件名字为中文名字。