commons-fileupload上传文件

commons-fileupload上传文件

前台jsp页面注意:

<form action="<%=basePath %>servlet/UploadServlet" enctype="multipart/form-data" method="post">

jsp页面:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"http://www.likecs.com/"; out.println(basePath); // :80/test/ %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="http://www.likecs.com/<%=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"> <!-- <link type="text/css" href="http://www.likecs.com/styles.css"> --> </head> <body> <form action="<%=basePath %>servlet/UploadServlet" enctype="multipart/form-data" method="post"> 上传用户:<input type="text"><br/> 上传文件1:<input type="file"><br/> 上传文件2:<input type="file"><br/> <input type="submit" value="提交"> </form> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzyxpd.html