A strange thing about the Servletrequest.getparameter () method was found today.
If the enctype of the form form is application/x-www-form-urlencoded (the value is a default value and does not need to be explicitly declared), then in the filter or servlet, We can get the corresponding parameter value directly through Request.getparameter (), if the form form's enctype is multipart/form-data (the upload image needs to declare the value), if no additional code is used to parse the input stream, In a filter or servlet, calling Request.getparameter () returns NULL.
The Hiddenhttpmethodfilter class of Spring MVC obtains the enhanced HTTP method by invoking Request.getparameter ("_method") in the Dofilterinternal () method. such as Patch,delete. However, if the enctype of the submitted form is Multipart/form-data, the Request.getparameter ("_") is invoked in the Hiddenhttpmethodfilter dofilterinternal () method. Method "), returns NULL, and an error occurs.
Two ways to solve this problem:
1. If the form's enctype is multipart/form-data, the form should not contain <input type= "hidden" name= "_method"/>, and vice versa.
2, before the request arrives hiddenhttpmethodfilter, resolves the form, and wraps the request, so that in Hiddenhttpmethodfilter dofilterinternal () Call Request.getparameter ("_method") in the method returns the correct value.
To supplement the class associated with this issue: Multipartfilter