Download .xls file in Spring with POST

1

Galera,

To download a file in Spring, I'm using the GET method.

@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());
    }

It would be possible to download via POST method

@RequestMapping(value = "/exportar", method = RequestMethod.POST)
    
asked by anonymous 24.04.2017 / 14:58

0 answers