struts2.0 文件上传问题
我的代码
public String execute() throws Exception
{
for (int i = 0; i < file.size(); ++i)
{
InputStream is = new FileInputStream(file.get(i));
String root = ServletActionContext.getRequest().getRealPath("/upload");
File destFile = new File(root, this.getFileFileName().get(i));
OutputStream os = new FileOutputStream(destFile);
byte[] buffer = new byte[400];
int length = 0;
while ((length = is.read(buffer)) > 0)
{
os.write(buffer, 0, length);
}
is.close();
os.close();
}
return SUCCESS;
}
问题是 我提交上传后 并没有 在 “upload”文件夹下出现我上传的文件?谁能帮我解惑?(控制台未出现任何异常)
public String execute() throws Exception
{
for (int i = 0; i < file.size(); ++i)
{
InputStream is = new FileInputStream(file.get(i));
String root = ServletActionContext.getRequest().getRealPath("/upload");
File destFile = new File(root, this.getFileFileName().get(i));
OutputStream os = new FileOutputStream(destFile);
byte[] buffer = new byte[400];
int length = 0;
while ((length = is.read(buffer)) > 0)
{
os.write(buffer, 0, length);
}
is.close();
os.close();
}
return SUCCESS;
}
问题是 我提交上传后 并没有 在 “upload”文件夹下出现我上传的文件?谁能帮我解惑?(控制台未出现任何异常)
...全文
相关推荐
struts2文件上传
本文将深入探讨Struts2文件上传的实现原理、步骤以及可能遇到的问题。一、基础知识1.
Struts2.0文件上传进度
在Struts2.0框架中,文件上传是一个常见的功能,特别是在处理大文件或者需要用户反馈上传状态的应用场景中。
struts2.0上传下载实例
本实例重点讲解Struts2.0中的文件上传和下载功能,这对于任何处理用户数据交互的Web应用都是必不可少的特性。
Struts2.0文件上传原理
以下是对Struts2.0文件上传原理的详细解释:1.
struts2文件上传例子.rar
Struts2提供了方便的文件上传支持,使开发者可以轻松地实现这一功能。在“struts2文件上传例子.rar”这个项目中,开发者已经使用Struts2.0框架实现了一个简单的文件上传功能。


Web 开发
