request.getPart
时间: 2023-09-09 22:10:15 浏览: 51
request.getPart() is a method in the Servlet API that is used to retrieve a specific part of a multipart request. A multipart request is a type of HTTP request that can contain multiple parts, such as files or form data.
The getPart() method takes a String parameter that represents the name of the part to retrieve. It returns an instance of the Part interface, which represents a single part of the multipart request.
Here is an example usage of the getPart() method:
```
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Part filePart = request.getPart("file");
// do something with the filePart
}
```
In this example, the getPart() method is used to retrieve the part of the request with the name "file". The returned Part object can then be used to access the content of the file that was uploaded as part of the request.