package com.demo.struts;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class Upload extends ActionSupport {
private File upload;
private String uploadContentType;
private String uploadFileName;
private String savePath;
public File getUpload() {
return 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() {
return ServletActionContext.getRequest().getRealPath(savePath);
}
public void setSavePath(String savePath) {
this.savePath = savePath;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("-----------------------------------------");
ActionContext ctx=ActionContext.getContext();
savePath="/upload";
System.out.println(savePath);
if(upload==null){
System.out.println("upload is null!");
}
System.out.println(getSavePath() + "\\"+ getUploadFileName());
FileOutputStream fos = new FileOutputStream(getSavePath() + "\\"+ getUploadFileName());
FileInputStream fis = new FileInputStream(getUpload());
byte[] buffer = new byte[1024];
int length = 0;
while ((length = fis.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
ctx.put("Msg", "上传成功!");
//System.out.println("上传成功!");
return "success";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ajax+jquery+struct+ajaxfileupload有增删改功能上传文件例子
共18个文件
xml:3个
js:2个
jsdtscope:1个
需积分: 9 13 下载量 177 浏览量
2014-11-18
16:26:58
上传
评论
收藏 29KB RAR 举报
温馨提示
ajax+jquery+struct+ajaxfileupload有增删改功能上传文件例子
资源推荐
资源详情
资源评论
收起资源包目录
upload例子.rar (18个子文件)
ajaxFileUpload
.mystrutsdata 240B
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
src
com
demo
struts
Upload.java 2KB
struts.xml 495B
.project 1KB
WebRoot
upload
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 677B
classes
com
demo
struts
Upload.class 3KB
struts.xml 495B
lib
jquery-1.2.6.min.js 54KB
index.jsp 2KB
ajaxfileupload.js 7KB
loading.gif 4KB
.mymetadata 315B
.classpath 463B
.myeclipse
共 18 条
- 1
资源评论
xdtitan
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功