Restful与Spring MVC

 

Spring工作流程:

 

 文件上传的处理:

 

解析参数的过滤器:

<filter>
		<filter-name>MultipartFilter</filter-name>
		<filter-class>org.springframework.web.multipart.support.MultipartFilter</filter-class>
		<init-param>
			<param-name>multipartResolverBeanName</param-name>
			<param-value>multipartResolver</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>MultipartFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

  转换http动作的:

<filter>
		<filter-name>hiddenHttpMethodFilter</filter-name>
		<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>hiddenHttpMethodFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

  错误页面信息:

解决方法:

 

 代码:

<!-- 配置文件上传解析器 -->
	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> 
         <!-- 指定所上传文件的总大小不能超过20M。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 --> 
         <property name="maxUploadSize" value="20000000"/>
         <property name="defaultEncoding" value="utf-8"></property>
    </bean>

  

posted @ 2019-05-26 19:30  石shi  阅读(187)  评论(0编辑  收藏  举报