Recently in the background of a website, but related to the implementation of the editing function, due to the implementation of the file upload function, it is necessary to introduce enctype= "multipart/form-data" in form form, but after introduction, the program runs to show errors, Get Method.patch, even though I have added <input type= "hidden" name= "_method" value= "PATCH" in the form form; Added Hiddenhttpmethodfilter to the Web. xml file, the page shows post not supported, but I replaced the patch with the original post without problems, so I found out that the problem was when introducing enctype= "multipart /form-data ", Hiddenhttpmethodfilter inside the Request.getparam get not value, find a lot of information on the Internet, there are others encounter this problem, the final solution is
1. In controller incoming @requestparam (value = "Avatarimage") multipartfile avatarimage the Type field to accept the upload file in form form
2. Add <filter> before Hiddenhttpmethodfilter
<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> a layer of packaging for the request, after which you can get the value of the request
This finally solved my problem, but I am not very clear about the principle behind, hope to understand thoroughly, can share with me.