when i try to upload multiple files, MultipartFile [] trainerProvider in the trainer controller is null. below is the code, please do help me out.
trainer.jsp
$(function() { $("form#data").submit(function(event){ event.preventDefault(); var url = '${pageContext.request.contextPath}/eduskill/trainer/upload'; var trainerProviderLogo = document.getElementById("trainingProviderLogo".files); var formData = new FormData(); formData.append("trainerProviderLogo", trainerProviderLogo); $.ajax({ url: url, type: 'POST', data: formData, async: false, cache: false, contentType: false, processData: false, success: function (status) { // do something on success } }); return false; });
});
<form id="data"> <div class="form-inline row"> <label class="col-md-4">Training Provider Logo:</label> <input class="col-md-5 new1-col" type="file" name="trainerProviderLogo[]" multiple="multiple" id="trainingProviderLogo" accept="image/*"> </div> </form>
培训师控制器
@RequestMapping(value = { ControllerUriConstant.upload }, method = RequestMethod.POST) public @ResponseBody String becomeTrainer( @RequestParam("trainerProviderLogo") MultipartFile[]
trainerProviderLogo)抛出IOException,TechnoShineException {}
[从ajax方面上传的数据] [1]