我正在编写一个网络应用程序,我想将一个文件上传到 servlet。我读到我可以使用 ServletFileUpload.parseRequest(request) 它在一台计算机上工作。但是当我尝试在另一台计算机上运行代码时,我收到一个错误,该函数需要 RequestContext: ServletFileUpload.parseRequest(RequestContext)
在该函数与 HttpServletRequest 一起使用的计算机上,我看到该函数与 RequestContext。但我不使用它
有没有另一种方法可以将文件上传到 servlet?
小智 5
你可以试试:
new ServletFileUpload().parseRequest(new ServletRequestContext(request));
Run Code Online (Sandbox Code Playgroud)
此更改适用于最新的 apache tomcat(至少在我使用的 7.0.70 上)。