@RequestMapping(value = "/download")
@ResponseBody
public void download(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException {
//设置中文文件名与后缀
String filename= URLEncoder.encode("中文文件名称") + ".docx","utf-8").replaceAll("\\+", "%20");
// 清除buffer缓存
response.reset();
// 指定下载的文件名
response.setHeader("Content-Disposition",
"attachment;filename="+filename+"");
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
...........
} catch (Exception e) {
e.printStackTrace();
}
}