📄 muluploadaction.java
字号:
package com.ata.upload;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class MulUploadAction extends ActionSupport{
private String title;
private File[] upload;
private String[] uploadContentType;
private String[] uploadFileName;
private String savePath;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public File[] getUpload() {
return (this.upload);
}
public void setUpload(File[] upload) {
this.upload = upload;
}
public String[] getUploadContentType() {
return uploadContentType;
}
public void setUploadContentType(String[] uploadContentType) {
this.uploadContentType = uploadContentType;
}
public String[] getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String[] uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getSavePath() throws Exception {
return ServletActionContext.getRequest().getRealPath(savePath);
}
public void setSavePath(String value) {
this.savePath = value;
}
public String execute() throws Exception{
File[] files=getUpload();
for(int i=0;i<files.length;i++){
FileOutputStream fos=new FileOutputStream(getSavePath()+"\\"+getUploadFileName()[i]);
FileInputStream fis= new FileInputStream(files[i]);
byte[] buffer=new byte[1024];
int len=0;
while((len=fis.read(buffer))>0){
fos.write(buffer,0,len);
}
}
return SUCCESS;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -