struts实现单文件上传
来源:互联网 发布:绑定网卡linux 6.5 编辑:程序博客网 时间:2024/05/22 06:34
1.定义一个用于文件上传的jsp页面
2.配置struts.xml
3.定义后台类
public class upload implements Action{ 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.getServletContext().getRealPath(savePath); } public void setSavePath(String savePath) { this.savePath = savePath; } public String execute() throws Exception { byte[] bytes=new byte[1024]; FileInputStream fileInputStream=new FileInputStream(getUpload()); FileOutputStream fileOutputStream=new FileOutputStream(getSavePath()+"//"+getUploadFileName()); int read = fileInputStream.read(bytes); while (read>0){ fileOutputStream.write(bytes,0,read); read=fileInputStream.read(bytes); } fileOutputStream.flush(); fileOutputStream.close(); fileInputStream.close(); return SUCCESS; }}
阅读全文
0 0
- struts实现单文件上传
- struts 单文件上传
- struts 单文件文件上传
- Struts文件上传--1.单文件上传
- struts--实现上传文件
- struts 实现文件上传
- struts 实现文件上传
- struts实现文件上传
- struts实现文件上传
- Struts实现文件上传。
- Struts单、多个文件的上传
- 用Struts实现文件上传
- struts上传文件的实现
- struts实现多文件上传
- struts 2实现文件上传
- struts实现文件上传程序
- Struts 2 实现上传文件
- struts实现upload文件上传
- cURL error 60: SSL certificate problem: unable to get local issuer certificate 解决思路
- Oracle监听日志定期清理
- 非MFC工程使用MFC库
- C# 数据库连接池
- 类的六个默认成员函数
- struts实现单文件上传
- 浅谈Android Studio3.0更新之路(遇坑必入)
- 0基础lua学习(八)字符串
- python高级学习目录
- Spring Http Invoker使用简介
- 迷题
- 拦截请求的三种方式 Filter、Interceptor、Aspect
- 一个简易的区块链demo
- 【HDU