gistfile1.txt package com.fz.servlet;import java.io.File;import java.io.IOException;import java.util.Collection;import java.util.UUID;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResp
package com.fz.servlet; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.UUID; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.Part; @WebServlet("/ups.do") @MultipartConfig public class Ups extends HttpServlet{ @Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest)req; String name = request.getParameter("name"); // Part part = request.getPart("ifile"); //文件路径 String path = this.getServletContext().getRealPath("upload/"); File file = new File(path); if (!file.exists()) { file.mkdirs(); } //获取文件集合 Collectionlist = request.getParts(); for (Part p : list) { if(p.getContentType()==null) continue; //设置文件大小 int size = 1024*50; if (p.getSize()