Configuration in Spring-root.xml
<bean id= "Multipartresolver" class= "Org.springframework.web.multipart.commons.CommonsMultipartResolver" >
<property name= "maxuploadsize" value= "9000000"/>
<property name= "maxinmemorysize" value= "/>"
</bean>
Controller
@RequestMapping (value= "/upload.do", method = Requestmethod.post)
@ResponseBody
Public String batchimport (@RequestParam multipartfile myFile, httpservletrequest request,httpservletresponse response ) {
Form
<form action= "upload.do" enctype= "Multipart/form-data" method= "POST" >
<input type= "File" name= "MyFile"/>
<input type= "Submit" value= "upload!"/>
</form>
When a Web request arrives at Dispatcherservlet and waits for processing, Dispatcherservlet first checks to see if it can find a name called Multipartresolver from its own webapplicationcontext ( Determined by the Dispatcherservet Multipart_resolver_bean_name) instance. If you can get this instance, Dispatcherservlet will check whether the current Web request is a multipart type through the Multipartresolver Ismultipart (Request) method. If so, Dispatcherservlet will call Multipartresolver's Resolvemultipart (Request) method, return Multiparthttpservletrequest, Otherwise, return HttpServletRequest.
Here, I stepped on the pit, online said the basic configuration here basically completed the upload function of the file, but here I stepped on the pit, be sure to put the form to submit the way to set the Post,controller also want to change!!
Springmvc uploading files and stepping over the pits