1. 文件上傳需要在form表單中添加<form enctype="multipart/form-data">
2. SpringMVC默認是關閉fileupload功能的,開啟該能夠並驗證文件上傳:
需要在applicationcotent.xml中做如下配置:
文件上傳
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="100000"/> <property name="maxInMemorySize" value="10240" /> </bean>
或需要在web.xml的servlet中做最大文件上傳配置
<multipart-config> <max-file-size>10000000000</max-file-size> </multipart-config>