Servlet 3 upload file uploading practice in Java Web
In the version before servlet 3.0, file upload is a headache. Although it is implemented by a third-party framework, it is still troublesome to use. In servlet 3.0, these problems will no longer exist. Servlet 3.0 provides direct support for file upload. In conjunction with the annotations based configuration in servlet 3.0, the operation of uploaded files is greatly simplified.
1、 Javax servlet. Part interface in http
public interface Part
To upload a file, you must use multipart / form data as the request body.
edition:
Servlet 3.1 - Apache Tomcat 8.0. thirty-three
2、 Method overview
3、 @ multipartconfig annotation
The servlet used to handle file upload must use the @ multipartconfig annotation, which has four attributes.
4、 Servlet to handle file upload
5、 Front end HTML page
Servlets are registered using annotations, so there is no need to use web XML file. Create a new web project and use these two files to deploy to Tomcat. The URL to access is http://localhost:8080/UploadFileTest/UploadFile.html