配置spring-mvc.xml
<!-- 上傳文件配置 2048*1024*1024即2GB resolveLazily屬性啟用是為了推遲文件解析,以便捕獲文件大小異常 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!---->
<!--<property name="maxUploadSize" value="2147483648"/>-->
<property name="maxUploadSize" value="20480"/>
<property name="maxInMemorySize" value="10240"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="resolveLazily" value="true"/>
</bean>
配置ngnix
server { listen 80; server_name www.xxx.com; location / { client_max_body_size 2048m; //設置文件上傳最大限制 2G proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8081; index index.jsp index.html index.htm; } }
