Ajaxupload and Spring MVC
If you upload the file through a regular form, then it works. If you upload the file / files using ajaxupload nothing works.
Mistake:
org.springframework.web.multipart.MultipartException: The current request is not a multipart request
Code:
@RequestMapping (value = "/ upload", method = RequestMethod.POST)
public void upload (@ RequestParam MultipartFile file,
HttpServletRequest request, HttpServletResponse response)
The goal is multi-uploading files with ajax, can anyone have a working example for Spring.
I have a separate servlet that gets HttpServletRequest
and parses everything is fine. On the client side ajaxupload.
If you try a simple Spring MVC transfer request in this class, it will refuse to work, claiming that the request is not multipart. Spring turns out how to cut the original request?
Modify the upload.js file, find and comment out the line that has "application / octet-stream"
and add the following line: xhr.setRequestHeader ("Content-Type", "multipart / form-data");