【发布时间】:2017-08-22 16:46:31
【问题描述】:
这让我很困惑。在下面的代码中,控制台中甚至没有打印出“1”。如果我在第一个 system.out 行中放置一个断点(使用 eclipse),调试器永远不会退出它。没有抛出异常。我还尝试将空参数传递给 SFU 的构造函数以强制它抛出异常,但什么也没发生。
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("1");
try {
ServletFileUpload upload = new ServletFileUpload();
} catch (Throwable e) {
throw new ServletException(e);
}
System.out.println("2");
}
还有html
<!DOCTYPE html>
<html lang="en">
<head>
<title>File Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method="POST" action="loadFile" enctype="multipart/form-data" >
<input type="file" name="myFile" id="myFile" /> <br/>
<input type="submit" value="Upload" name="upload" id="upload" />
</form>
</body>
</html>
【问题讨论】:
标签: apache servlets apache-commons-fileupload