java - How can I send the data from a imput type="file" to the controller? -


i have in ftl:

<input type="file" id="doc6" name="documente"> 

in .js:

var lx = $("#longx").val(); var ly = $("#laty").val(); var jud = $("#judetpunctlucru").val(); var doc6type = $("#doc6type").val(); var doc6 = $('doc6').val();  validatecoords: function (lx, ly, jud, doc6type, doc6) {             var data = {                 lx: lx,                 ly: ly,                 jud: jud,                 doc6type: doc6type,                 doc6: doc6             };             var url = contextpath + '/validarecoord';             return getjsondata(url, data);         } 

and in controller:

@requestmapping(value = "/validarecoord", method = requestmethod.get, produces = mediatype.application_json_value)     @responsebody     public map<string, object> getvalidcoord(@requestparam("lx") string lx,                                              @requestparam("ly") string ly,                                              @requestparam("jud") string jud,                                              @requestparam(value = "doc6type", defaultvalue = "") final string doc6type,                                              @requestparam(value = "doc6", required=false) multipartfile doc6){ ..... } 

but doc6 not need when read , error is:

error: org.springframework.web.multipart.multipartexception: current request not multipart request 

can tell me how should read data file? var doc6 = $('doc6').val(); it's not ok.

you should try add headers in @requestmapping :

headers = "content-type=multipart/*" 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -