struts2实现文件上传 代码
来源:互联网 发布:商丘淘宝的产业基地 编辑:程序博客网 时间:2024/06/06 09:44
public class FileUpLoad extends ActionSupport{//"多文件上传就用list就可以了private List<File> file;"private File file;//上传文本的namepublic File getFile() {return file;}public void setFile(File file) {this.file = file;}private String fileContentType;//上传的文件类型。public String getFileContentType() {return fileContentType;}public void setFileContentType(String fileContentType) {this.fileContentType = fileContentType;}//获取上传文件的名称private String fileFileName;public String getFileFileName() {return fileFileName;}public void setFileFileName(String fileFileName) {this.fileFileName = fileFileName;}public String upload() throws Exception{//获取文件上传路径String root=ServletActionContext.getRequest().getRealPath("/upload");InputStream is=new FileInputStream(file);String.substring(fileFileName.indexOf("."));//截取上传文件的后缀。便于新定义名称。.jpgSystem.out.println(name);File descFile=new File(root,新定义的文件名称+fileFileName.indexOf("."));OutputStream os=new FileOutputStream(descFile);byte[] buffer=new byte[1024];int length=0;while(-1!=(length=(is.read(buffer)))){os.write(buffer, 0, length);}is.close();os.close();return SUCCESS;}}
0 0
- struts2实现文件上传 代码
- Struts2上传文件代码
- Struts2实现文件上传
- struts2实现文件上传
- struts2实现文件上传
- Struts2实现文件上传
- struts2实现文件上传
- struts2实现文件上传
- struts2实现文件上传
- struts2实现文件上传
- struts2实现文件上传
- Struts2实现文件上传
- Struts2实现文件上传
- Struts2实现文件上传
- Struts2实现文件上传
- struts2实现上传文件
- Struts2实现文件上传
- Struts2实现文件上传
- 多维数组的顺序表示
- Core Data详解
- Android 产品设计 原则
- beyond compare 中文乱码解决方案
- LaTeX学习(1):第一个LaTeX文件模板
- struts2实现文件上传 代码
- RCP产品自动加载plugins下面插件方法
- Exadata x2-2 (2节点rac+3 台存储服务器)问题
- svn Locked的几种解决方法
- 读金庸故事,品程序人生--杀死你的执着
- Android <uses-sdk> 注释
- 稀疏矩阵的转置
- DataGridView列排序混乱的处理方法
- PHP基础加强(第七天)