package com.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.struts2.ServletActionContext;
import com.model.Picture;
import com.opensymphony.xwork2.ActionSupport;
public class PictureAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private File file;
private String fileFileName;
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
/**
* 用于实现上传功能
*/
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
//实现上传
InputStream is = new FileInputStream(file);
String root = ServletActionContext.getRequest().getRealPath("/upload");
System.out.println(this.getFileContentType() );
File deskFile = new File(root,this.getFileFileName());
OutputStream os = new FileOutputStream(deskFile);
byte [] bytefer = new byte[400];
int length = 0 ;
while((length = is.read(bytefer) )>0)
{
os.write(bytefer,0,length);
}
os.close();
is.close();
return SUCCESS;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
swfupload_struts2
共29个文件
jar:7个
js:4个
jsp:3个
4星 · 超过85%的资源 需积分: 10 110 下载量 180 浏览量
2011-04-07
08:35:35
上传
评论 1
收藏 3.39MB RAR 举报
温馨提示
在struts2环境下配置之后就可以有上传图片和大文件的功能 可以在tomcat下发布运行
资源推荐
资源详情
资源评论
收起资源包目录
swfupload_struts2.rar (29个子文件)
swfupload
.project 1KB
.mymetadata 300B
WebRoot
css
default.css 6KB
WEB-INF
web.xml 696B
lib
ognl-2.6.11.jar 164KB
commons-logging-1.0.4.jar 37KB
xwork-2.0.5.jar 447KB
commons-io-1.4.jar 106KB
freemarker-2.3.8.jar 784KB
commons-fileupload-1.2.1.jar 56KB
struts2-core-2.0.11.2.jar 2.22MB
classes
com
action
PictureAction.class 2KB
model
Picture.class 628B
struts.xml 394B
index.jsp 5KB
upload.jsp 575B
META-INF
MANIFEST.MF 39B
MyJsp.jsp 837B
images
XPButtonUploadText_61x22.png 2KB
js
fileprogress.js 7KB
swfuploadbutton.swf 3KB
swfupload.swf 12KB
swfupload.js 38KB
handlers.js 7KB
swfupload.queue.js 3KB
.myeclipse
src
com
action
PictureAction.java 2KB
model
Picture.java 312B
struts.xml 394B
.classpath 921B
共 29 条
- 1
nongchao2011
- 粉丝: 15
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页