The SPRINGMVC in the Multipartfile property is used to receive type= "file" in the front-end form submission
To use the Multipartfile property, you only need to configure the configuration multipartresolver in Servlet.xml:
<BeanID= "Multipartresolver"class= "Org.springframework.web.multipart.commons.CommonsMultipartResolver"> < Propertyname= "Maxuploadsize"value= "1024000"></ Property> < Propertyname= "Defaultencoding"value= "Utf-8"></ Property> </Bean>
The specific other parameters can be self-Baidu
The attributes are detailed in the following:
Defaultencoding configuration Request encoding format, default to Iso-8859-1 (contains Chinese name of the file to configure Utf-8, otherwise background use Getoriginalfilename () will be garbled)
Maximum unit of maxuploadsize configuration file, in bytes
In addition, the front-end form needs to be set Enctype code, set to: Enctype= "Multipart/form-data"
Related definitions:
(The Enctype property specifies how the form data should be encoded before it is sent to the server.)
By default, the form data is encoded as "application/x-www-form-urlencoded". That is, all characters are encoded before being sent to the server (spaces are converted to "+" plus signs, and special symbols are converted to ASCII HEX values). )
Finally, the Formdata object is used to receive a file, and the client interface is invoked to xmlhttprequest the data to the controller on the background (the process can be simplified to use AJAX)
The front end can increase the description of the file information (save path, file name redefinition, etc.), with the file sent to the background controller, so that the server FTP
Front-end file upload also has a lot of powerful plug-ins, such as uploadify can set the transmission progress
SPRINGMVC Jquery-ajax Building Server FTP