我知道有很多jquery插件可用于文件上传。但它只是展示了我们如何将其添加到jsp页面中。但我想知道我们如何处理在后台使用这些插件选择的文件。例如,我在struts2中使用spring。因此,我想从jsp将这些文件发送到操作类中,并将其存储在服务器位置。任何人都知道我该怎么做。
userImage
是<file>
标签的名称
public class FileUploadAction extends ActionSupport{
private File userImage;
private String userImageContentType;
private String userImageFileName;
private HttpServletRequest servletRequest;
public String execute() {
try {
String filePath = "yourPath";
File fileToCreate = new File(filePath, this.userImageFileName);
FileUtils.copyFile(this.userImage, fileToCreate);
} catch (Exception e) {
e.printStackTrace();
addActionError(e.getMessage());
return INPUT;
}
return SUCCESS;
}
}
从本教程
本教程解释了多文件上传usinf List