Struts2 上传文件方法
来源:互联网 发布:苹果铃声制作软件 编辑:程序博客网 时间:2024/05/21 20:26
private File file;//跟表单里面空间名称一致private String fileFileName;//上传文件的名称private String newFileName;//新的文件名(UUID)public String upFile(){ try { //获取file文件夹在服务器上的完整路径 String filePath = ServletActionContext.getServletContext().getRealPath("/FilePath"); //获取新文件名的唯一ID(名字) String fileId = UUID.randomUUID().toString(); //获取上传文件的后缀名 String subName = fileFileName.substring(fileFileName.indexOf(".")); //新的文件名 newFileName = fileId+subName; //新文件的完整路径 String newFilePath = filePath+"/"+newFileName; //目标文件 File destFile = new File(newFilePath); //上传文件的方法,struts2封装好的 FileUtils.copyFile(file, destFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return "error"; } return SUCCESS; }
0 0
- Struts2 上传文件方法
- struts2文件上传(Servlet方法)
- struts2文件上传(Action方法)
- Struts2 上传文件时取得文件扩展名的最好方法
- struts2上传文件(三) struts2上传文件
- [Struts2]Struts2的文件上传
- Struts2的文件上传
- Struts2文件上传
- Struts2 上传文件实例
- struts2文件上传
- struts2文件上传
- Struts2的文件上传
- struts2-上传文件(1)
- struts2-上传文件(2)
- Struts2上传文件示例
- struts2文件上传
- Struts2实现文件上传
- struts2文件上传
- qt学习笔记(一)之Hello world
- Dragon of Loowater
- Linux下JDK中文字体乱码
- UIButton UIEdgeInsetsMake
- LintCode 丑数
- Struts2 上传文件方法
- java架构师之路:JAVA程序员必看的15本书的电子版下载地址
- Ubuntu 12.04安装python3.4
- activemq的三种基本通信方式
- NGX负载均衡策略
- 多线程文件复制
- 单机tcp并发连接
- android软件更新
- android4.4从系统图库无法加载图片的问题