使用Struts 2框架上传文件(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-06 18:18 点击:次
private String[] attachmentContentType;
或
private List<File> attachmentFile; private List<String> attachmentFileName; private List<String> attachmentContentType;
第三步、将上传的文件保存到一个指定的文件夹下或数据库中。
示例:Struts 2单文件上传
接收上传文件的动作类:
public class SingleFileUploadAction extends ActionSupport { private static final long serialVersionUID = 742220866388022377L; private File attachment; // 用户上传的文件 private String attachmentFileName; // 上传文件的文件名 private String attachmentContentType; // 上传文件的类型 private String description; // 用户的描述 /* * SingleFileUploadAction的属性的getter和setter方法 */ public File getAttachment() { return attachment; } public void setAttachment(File attachment) { this.attachment = attachment; } public String getAttachmentFileName() { return attachmentFileName; } public void setAttachmentFileName(String attachmentFileName) { this.attachmentFileName = attachmentFileName; } public String getAttachmentContentType() { return attachmentContentType; } public void setAttachmentContentType(String attachmentContentType) {
相关新闻>>
- 发表评论
-
- 最新评论 更多>>