Upload file with POST request with Spring?

to upload a file using Spring, I use 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());
    }

      

How can I achieve this using POST? Is it possible?

@RequestMapping(value = "/exportar", method = RequestMethod.POST)

      

+3
java spring spring-data


source to share


No one has answered this question yet

See similar questions:

51
Returning a generated pdf using spring MVC

or similar:

1873
What's the difference between @Component, @Repository and @Service annotations in Spring?
1695
How to use java.net.URLConnection to trigger and process HTTP requests
1571
How to avoid Java code in JSP files?
964
Download file from Android and show progress in ProgressDialog
866
How to solve "Executing plugins not covered by lifecycle config" for Spring Data Maven Builds
333
Loading file from spring controllers
0
How to link Elasticsarch results to a Spring REST API response
0
Prevent javascript file caching, Spring
0
Watermark dynamically generated pdf in google engine



All Articles
Loading...
X
Show
Funny
Dev
Pics