gpt4 book ai didi

java - ServletFileUpload.parseRequest() 需要 RequestContext 而不是 HttpServletRequest 请求

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:41 30 4
gpt4 key购买 nike

我正在编写一个网络应用程序,我想将一个文件上传到 servlet。我读到我可以使用 ServletFileUpload.parseRequest(request)它适用于一台计算机。但是当我尝试在另一台计算机上运行代码时,我得到一个错误,该函数需要 RequestContext: ServletFileUpload.parseRequest(RequestContext)

在该函数与 HttpServletRequest 一起使用的计算机上,我看到该函数与 RequestContext 一起使用。但我不使用它

还有其他方法可以将文件上传到servlet吗?

最佳答案

你可以试试:

new ServletFileUpload().parseRequest(new ServletRequestContext(request));

此更改适用于最新的 apache tomcat(至少适用于我正在使用的 7.0.70)。

关于java - ServletFileUpload.parseRequest() 需要 RequestContext 而不是 HttpServletRequest 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19065204/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com