使用Spring下载文件时,我正在使用GET方法。
@RequestMapping(value = "/exportar/{tipo}", method = RequestMethod.GET)
@ResponseBody
public void exportar(HttpServletResponse response,@PathVariable TipoEnum tipo) throws IOException{
File file = service.exportar(tipo);
response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", file.getName() + ".xls"));
response.setContentType("application/ms-excel; charset=UTF-8");
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
FileCopyUtils.copy(inputStream, response.getOutputStream());
}
我该如何使用POST方法实现这个?这个可行吗?
@RequestMapping(value = "/exportar", method = RequestMethod.POST)