JAVA Servlet 上传批量上传大文件
新建类 UploadServlet
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"> </head> <body> <form action="<%=basePath %>upload" method="post" enctype="multipart/form-data"> <input type="file" name="file"/> <input value="name" name="name" type="text" /> <input type="submit"/> </form> </body></html>
依赖的jar包,commons-fileupload-1.1.jar 和 commons-io-1.1.jar