使用Struts 2框架上传文件(8)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-06 18:18 点击:次
public class MultiFileUploadAction extends ActionSupport { private static final long serialVersionUID = -5056971793538814980L; private List<File> fileFile; private List<String> fileFileName; private List<String> fileContentType; public List<File> getFileFile() { return fileFile; } public void setFileFile(List<File> fileFile) { this.fileFile = fileFile; } public List<String> getFileFileName() { return fileFileName; } public void setFileFileName(List<String> fileFileName) { this.fileFileName = fileFileName; } public List<String> getFileContentType() { return fileContentType; } public void setFileContentType(List<String> fileContentType) { this.fileContentType = fileContentType; } @Override public String execute() { if (fileFile.size() == 0) { return INPUT; } else { for (int index = 0; index < fileFile.size(); index++) { String targetDir = "d:\\images"; File savedFile = new File(targetDir, fileFileName.get(index)); fileFile.get(index).renameTo(savedFile); } } return SUCCESS; } }
struts.xml配置信息:
<action name="multi_upload" class="struts2.suxiaolei.fileupload.action.MultiFileUploadAction">
相关新闻>>
- 发表评论
-
- 最新评论 更多>>