Java tutorial
/** * Copyright (c) 2005-2012 https://github.com/zhangkaitao * * Licensed under the Apache License, Version 2.0 (the "License"); */ package com.sishuok.chapter4.web.servlet; import org.apache.commons.io.IOUtils; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Part; import java.io.IOException; import java.io.InputStream; /** * <p>User: Zhang Kaitao * <p>Date: 13-6-22 ?3:04 * <p>Version: 1.0 */ @MultipartConfig( fileSizeThreshold = 10000 //?? ) @WebServlet(name = "uploadServlet3", urlPatterns = "/upload3") public class UploadServlet3 extends HttpServlet { @Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { Part part = req.getPart("file1"); InputStream is = part.getInputStream(); System.out.println(IOUtils.toString(is)); is.close(); /** * jetty * fileSizeThreshold * 1?content-disposition??? * 2??byte array input stream * 3?[2]?fileSizeThreshold * * 4?? * 4.1?@MultipartConfiglocation? * 4.2?Part.write ? * */ } }