简体   繁体   中英

Downloading file on Spring Rest Web Service

I have a url on my Restful Web Service which has a url which loads a json file using ResponseEntity. Is there a way such that when I load the url, it still returns the json but in addition prompts the user to download the same json data in csv format? Is there like a way I can tell it to essentially return 2 files or something like that? Thanks!

REST is based on HTTP which is based on Request Response model. For each Request there can be only one Response.

You can do the expected in client code. For example you return a JSON with link to CSV Download URL.

{
   "csvUrl":"http..."
}

And from your client, be it Javascript or any other prompt user to download from csvUrl link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM