0

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() );
             }
    }
2
  • 1
    Possible duplicate of spring MVC multiple files upload Commented Sep 19, 2016 at 9:01
  • Not actually. I tried in the same way, but I am not getting correct to-attach file count in POST method. Trying to attach 2 but getting 1. Commented Sep 19, 2016 at 9:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.