Java上传文件时出错,求大神帮助 5C

上传文件时,文件能上传,就是报了一个错误,错误代码如下:

java.io.IOException: java.io.FileNotFoundException: E:\intelli IDEA\IntelliJ IDEA 2019.1.2.IntelliJIdea\system\tomcat\Unnamed_Potato_3\work\Catalina\localhost\ROOT\upload_153e9ccf_dc34_49cf_8013_597e0454a311_00000009.tmp (系统找不到指定的文件。)
at org.apache.catalina.core.ApplicationPart.write(ApplicationPart.java:122)
at com.potato.util.FileUpload.UpUpload(FileUpload.java:57)
at com.potato.servlet.uploadFile.doPost(uploadFile.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.potato.Filter.FilterEncoding.doFilter(FilterEncoding.java:32)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2508)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2497)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: E:\intelli IDEA\IntelliJ IDEA 2019.1.2.IntelliJIdea\system\tomcat\Unnamed_Potato_3\work\Catalina\localhost\ROOT\upload_153e9ccf_dc34_49cf_8013_597e0454a311_00000009.tmp (系统找不到指定的文件。)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.write(DiskFileItem.java:392)
at org.apache.catalina.core.ApplicationPart.write(ApplicationPart.java:120)
... 28 more

3个回答

报错不是很明显吗? upload_153e9ccf_dc34_49cf_8013_597e0454a311_00000009.tmp 这个文件找不到啊,自己看看代码

qq_25867659
qq_25867659 在 part.write那
11 个月之前 回复
weixin_39827826
治愈君 回复qq_25867659: 没有你的代码我也不知道是啥回事,你自己打断点看看,在哪里生成的
11 个月之前 回复
qq_25867659
qq_25867659 而且他这个文件还是一个临时文件,Tomcat启动一次重新生成一次
11 个月之前 回复
qq_25867659
qq_25867659 我知道找不到这个文件,这个文件根本就没有啊,而且我上传的目录不是这个也不是这个文件,我上传的东西上传完成了,但是就是要报这个错
11 个月之前 回复

你可以根据路径看一下找不到的文件是怎么回事,用debug测一下。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问