This is the 7th day of my participation in the August Gwen Challenge.

Long time no see you, people are still used to lazy, hard work is really against humanity. SpringMVC simplifies file uploading, and as a more simplified Springboot, it further encapsulates file uploading, making it more convenient to implement. Java file upload a total of two components, one is CommonsMuitipartResolver, another is StandardServeltMultipartResolver, including the use of common prefix is common – fileupload To handle multipart requests, while the Standard prefix is servlet-based to handle multipart requests.

This is the introduction to the previous article, which focused on single-file uploads, and today’s multi-file uploads. Just to enhance its functionality.

Multi-file upload is basically the same as single file upload, first modify the HTML file

Then modify the controller code core logic unchanged, just uploaded what also passed what, to pay attention to is to add a traversal step.

Multiple files are uploaded, the controller accepts an array of strings, iterates through the array, and stores them as they were, without major changes. The code is ugly, but it works, and it gets better and better. Effect:

Before uploading

After the upload

Finally, the website is returned in the form of a list of strings, or you can use another way, such as JSON might be better, to sum up, using Springboot file upload, because Springboot has helped us to solve the configuration problem of upload, so we just need to use it, and single file upload and more The only difference in file upload is that there is one more step to traverse in the controller. With a simple image upload logic, developers can focus on the business logic of image upload without spending too much time on configuration. Finally, I only want to call the weekend off, hope to get your attention and advice, the level is limited, thank you for watching.

Ps: I have to go to work to do the test recently, but I can’t do anything. Do you have a senior to give me some advice? My pleasure.