java檔案上傳SpringMVC的配置
阿新 • • 發佈:2019-02-11
<!-- 訪問靜態檔案(jpg,js,css)的方法 --> <mvc:resources location="/files/" mapping="/files/**" /> <mvc:resources location="/scripts/" mapping="/scripts/**" /> <mvc:resources location="/styles/" mapping="/styles/**" /> <mvc:resources location="/Views/" mapping="/Views/**" /> <!-- 多部分檔案上傳 需配置MultipartResolver處理器--> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="104857600" /> <property name="maxInMemorySize" value="4096" /> <property name="defaultEncoding" value="UTF-8"></property> </bean> <!-- SpringMVC在超出上傳檔案限制時,會丟擲org.springframework.web.multipart.MaxUploadSizeExceededException --> <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop> </props> </property> </bean>