request.getInputStream(); This method cannot get the data, but the buffer[bb] in the debug request object inputstreama gets the data,
The reason is due to the existence of the springmvc configuration file
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize"> <value>5242880</value> </property> </bean>
Intercept the configuration, so that although we obtain the byte stream but cannot read it normally, we can use the method that comes with springmvc (below):
public String springupload( @RequestParam("uploadfile")MultipartFile[] ajaxuploadfile, HttpServletRequest request, HttpServletResponse response, Model model) {
mainly through
ajaxuploadfile to operate.
If you do not use the file upload method that comes with spring, you can use the request.getInputStream(); method. However, reading through this method will have additional data that needs to be handled by yourself:
------WebKitFormBoundaryl7Arc1DpH0n7564m Content-Disposition: form-data; name="uploadfile"; filename="test.txt" Content-Type: text/plain test test test test test test test test test test test test test test test test test test test test ------WebKitFormBoundaryl7Arc1DpH0n7564m--