[英]How can I send the data from a imput type=“file” to the controller?
I have in the ftl: 我在ftl中:
<input type="file" id="doc6" name="documente">
in .js: 在.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 the 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 is not what I need when I read it like that and the error is: 但是当我这样阅读时,doc6不是我所需要的,并且错误是:
ERROR:
org.springframework.web.multipart.MultipartException: The current request is not a multipart request
can you tell me how should I read the data from file? 您能告诉我如何从文件中读取数据吗? clearly var doc6 = $('doc6').val();
显然var doc6 = $('doc6').val();
it's not ok. 不好
您应该尝试在@RequestMapping
添加标题:
headers = "content-type=multipart/*"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.