Struts2 java.io.FileNotFoundException

在使用Struts2进行文件上传时遇到`java.io.FileNotFoundException`,错误指出源文件不存在。问题出在指定的目标路径上。通过在`WEB-INF`下创建“images”文件夹后,问题得到解决。代码中已经包含了检查并创建目标目录的逻辑,但仍然出现错误,可能的原因是部署路径与预期不同。
摘要由CSDN通过智能技术生成

写了一个Struts2 上传文件的小程序,文件会放在images这个folder 下面,

String realpath = ServletActionContext.getServletContext().getRealPath("/images");


结果总是报错。 错误内容为: 

严重: Servlet.service() for servlet [default] in context with path [/Strutstest] threw exception [java.io.FileNotFoundException: Source 'C:\Users\shi edison\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\work\Catalina\localhost\Strutstest\upload_11c9e7e7_15bc986eee5__8000_00000000.tmp' does not exist] with root cause
java.io.FileNotFoundException: Source 'C:\Users\shi edison\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\work\Catalina\localhost\Strutstest\upload_11c9e7e7_15bc986eee5__8000_00000000.tmp' does not exist

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值