I am trying to do a multipart file upload.
I am annotating my controller withannotations. ( I would have put the atSigns's in there but apparently that means I am linking to another site outside of the forum, and I can't do that until I have posted 5 times, seems like a bug to me, but that's an aside)Code:Controller, RequestMapping and RequestParam
When the form is submitted I receive missing parameter exceptions, if I removed the enctype from the form, they resolve, but I lose the multipart file.
I have a multipart resolver declared in my applicationContextCode:<form action="uploadSubmit.view" enctype="multipart/form-data" method="POST">
The controller looks like thisCode:<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
Code:Controller public class UploadDestUrlReportController { RequestMapping("/upload.view") public ModelAndView handleUrlReport() { //do stuff return new ModelAndView("upload", modelMap); } RequestMapping("/uploadSubmit.view") public ModelAndView handleUrlReportUpload(HttpServletResponse response, RequestParam("id") int id, RequestParam("id2") int id2, RequestParam("file") MultipartFile f) throws IOException { Map<String, Object> modelMap = new HashMap<String, Object>(); if (f == null) { modelMap.put("msg", "null file"); return new ModelAndView("upload", modelMap); } modelMap.put("msg", "File ( " + f.getName() + ") uploaded"); return new ModelAndView("upload", modelMap); } }
Any ideas on what I could be missing?
Thanks,


Reply With Quote
