getting POST datas in java Spring Rest Server from $.fileDownload -


i've wrote application download file using jquery file download v1.2.0 plugin. in jquery file download v1.2.0 have option send datas post

post request data , query string

$.filedownload('/getafoo?a=b', { httpmethod : "post", data: { foo : "bar"}}) 

can please tell me how receive post datas on server side, i'm using java spring rest server

my code given below

script

var json ="[[\"name\",\"place\",\"phone\"]," + "[\"aaa\",\"hhh\",\"123\"]," + "[\"bbb\",\"\",\"254\"]," + "[\"ccc\",\"'#?\",\"\"]]";     $.filedownload(url,{ httpmethod : "post", data: { excelcontent : json}}).done(function(e, response)     {     }).fail(function(e, response)     {     }); 

java spring rest

@requestmapping(value = "filedownload", method = requestmethod.get, produces = app_json) @responsebody public void getmyfiledownload(final httpservletresponse response) throws ioexception, exception {         //how content of excelcontent on here } 

try code jee not spring, think same

    @get     @path("download")     @produces(mediatype.application_octet_stream)     public response exportscenario(@context final httpservletresponse resp) {         resp.setheader("cache-control", "public");         resp.setheader("pragma", "public");         return response.ok(new streamingoutput() {             public void write(final outputstream os) throws ioexception {                 // place write file data stream             }         }).header("content-disposition", "attachment; filename=\"file.zip\"").build();     } 

update: browser side:

$.ajax({     url : 'rest/configuration/add.json',     type : 'post',     contenttype: 'application/json',     data : $.tojson({         title : $('#conf_create_name')[0].value,          comment : $('#conf_create_comment')[0].value,         params : params     }), }); 

ajax post reauset json object $.tojson need additional jquery plugin search google.

server side:

    @post     @path("download")     @consumes(mediatype.application_json)     @produces(mediatype.application_octet_stream)     public response exportscenario(@context final httpservletresponse resp, final configurationdto confdto) {         resp.setheader("cache-control", "public");         resp.setheader("pragma", "public");         return response.ok(new streamingoutput() {             public void write(final outputstream os) throws ioexception {                 // place write file data stream             }         }).header("content-disposition", "attachment; filename=\"file.zip\"").build();     } 

configeratiodto:

public class configurationdto {     private string title;     private string comment;     private map<string, string> params;      public string gettitle() {         return title;     }      public void settitle(string title) {         this.title = title;     }      public string getcomment() {         return comment;     }      public void setcomment(string comment) {         this.comment = comment;     }      public map<string, string> getparams() {         return params;     }      public void setparams(map<string, string> params) {         this.params = params;     } } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -