@RequestMapping(value = "/download", method = RequestMethod.GET)
@ResponseBody
public Object download(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "pid") Long pid) throws IOException {
OutputStream os = null;
String files = xxxService.download(pid);
if (response != null) {
response.reset();
response.setHeader("Content-Disposition", String.format("attachment; filename=%s", "download.csv"));
response.setContentType(String.format("application/txt; charset=%s", "UTF-8"));
if (os == null) {
os = response.getOutputStream();
os.write(files.getBytes(StandardCharsets.UTF_8));
}
}
return null;
}