package jCuckoo;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.ServletActionContext;
import java.io.File;
import java.io.*;
import com.opensymphony.xwork2.ActionSupport;
public class UploadAction extends ActionSupport {
private String title;
private File upload;
private String uploadContentType;
private String uploadFileName;
// 接受依赖注入的属性
private String savePath;
// 接受依赖注入的方法
public void setSavePath(String value) {
this.savePath = value;
}
private String getSavePath() throws Exception {
return ServletActionContext.getRequest().getRealPath(savePath);
}
public void setTitle(String title) {
this.title = title;
}
public void setUpload(File upload) {
this.upload = upload;
}
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getTitle() {
return (this.title);
}
public File getUpload() {
return (this.upload);
}
public String getUploadContentType() {
return (this.uploadContentType);
}
public String getUploadFileName() {
return (this.uploadFileName);
}
@Override
public String execute() throws Exception {
// 以服务器的文件保存地址和原文件名建立上传文件输出流
FileOutputStream fos = new FileOutputStream(getSavePath() + "\\"+ getUploadFileName());
FileInputStream fis = new FileInputStream(getUpload());
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
return SUCCESS;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
我下载的一个练习我下载的一个练习
共27个文件
jar:8个
properties:4个
xml:3个
需积分: 0 2 下载量 21 浏览量
2008-12-12
17:39:39
上传
评论
收藏 7.7MB ZIP 举报
温馨提示
我下载的一个练习,是有关于一个控件的应用。
资源推荐
资源详情
资源评论
收起资源包目录
MY uploadStruts2.zip (27个子文件)
MY uploadStruts2
网文
uploadStruts2.rar 3.63MB
untitled.JPG 29KB
untitled1.JPG 50KB
uploadStruts2
.project 1KB
.settings
org.eclipse.core.resources.prefs 107B
.mymetadata 312B
WebRoot
WEB-INF
web.xml 711B
lib
log4j-1.2.9.jar 344KB
commons-io-1.3.1.jar 82KB
ognl-2.6.11.jar 164KB
commons-logging-1.0.4.jar 37KB
xwork-2.0.7.jar 449KB
freemarker-2.3.8.jar 784KB
struts2-core-2.0.14.jar 2.22MB
commons-fileupload-1.2.jar 52KB
classes
globalMessages.properties 162B
jCuckoo
UploadAction.class 2KB
struts.xml 954B
globalMessages_zh_CN.properties 316B
upload.jsp 543B
META-INF
MANIFEST.MF 39B
succ.jsp 355B
upload
src
globalMessages.properties 162B
jCuckoo
UploadAction.java 2KB
struts.xml 954B
globalMessages_zh_CN.properties 316B
.classpath 971B
共 27 条
- 1
资源评论
dlg2205
- 粉丝: 1
- 资源: 57
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功