问题
When I attach two or more files from my front end, in log.debug
used in the POST method I get only 01 file name and file list size also shows 01.
How can I get all my attached files in my POST method ???
I have my Model class as:
//Model
public class MailSenderBean {
private List<MultipartFile> files;
}
JSP View as below with enctype="multipart/form-data"
:
<input name="files" id="filesToUpload" class="button" type="file" multiple/>
Controller as:
//Controller
@RequestMapping(value = "/sendFiles", method = RequestMethod.POST)
public ModelAndView sendFiles(@ModelAttribute("mailSenderBean") MailSenderBean mailBean, BindingResult result,HttpServletRequest request) {
User user = AuthManager.getUser( request );
List<MultipartFile> files = mailBean.getFiles();
log.debug(" Size ---->>>> "+files.size());
for (MultipartFile multipartFile : files) {
log.debug("Name ===== >>> "+multipartFile.getOriginalFilename() );
}
}
来源:https://stackoverflow.com/questions/39569107/uploading-multiple-files-using-jsp-spring-with-single-browse-button-and-single