`
jackdraw
  • 浏览: 54905 次
  • 来自: ...
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

Tapestry上传多附件 [转]

阅读更多

以发送5个附件为实例:

private IUploadFile file0;

public IUploadFile getFile0() {
return file0;
}

public void setFile0(IUploadFile value) {
file0 = value;
}

protected void initialize() {
file0 = null;
}
private IUploadFile file1;

public IUploadFile getFile1() {
return file1;
}

public void setFile1(IUploadFile value) {
file1 = value;
}
private IUploadFile file2;

public IUploadFile getFile2() {
return file2;
}

public void setFile2(IUploadFile value) {
file2 = value;
}
private IUploadFile file3;

public IUploadFile getFile3() {
return file3;
}

public void setFile3(IUploadFile value) {
file3 = value;
}
private IUploadFile file4;

public IUploadFile getFile4() {
return file4;
}

public void setFile4(IUploadFile value) {
file4 = value;
}

-------------------------------------------------

List affixList = new ArrayList();
System.out.println("file= "+ this.getFile0());
if (this.getFile0()!= null) {
affixList.add(this.getFile0());
}
if (this.getFile1() != null) {
affixList.add(this.getFile1());
}
if (this.getFile2()!= null) {
affixList.add(this.getFile2());
}
if (this.getFile3()!= null) {
affixList.add(this.getFile3());
}
if (this.getFile4()!= null) {
affixList.add(this.getFile4());
}

-------------------------------------------------

List affixPathList = MailUtil.saveTempFile(visit.getUserid(),affixList);

/**
* 将上传的附件保存在临时文件夹
* @param dirName String
* @param affixList List
* @throws Exception
* @return List
*/
public static List saveTempFile(String

以发送5个附件为实例:

private IUploadFile file0;

public IUploadFile getFile0() {
return file0;
}

public void setFile0(IUploadFile value) {
file0 = value;
}

protected void initialize() {
file0 = null;
}
private IUploadFile file1;

public IUploadFile getFile1() {
return file1;
}

public void setFile1(IUploadFile value) {
file1 = value;
}
private IUploadFile file2;

public IUploadFile getFile2() {
return file2;
}

public void setFile2(IUploadFile value) {
file2 = value;
}
private IUploadFile file3;

public IUploadFile getFile3() {
return file3;
}

public void setFile3(IUploadFile value) {
file3 = value;
}
private IUploadFile file4;

public IUploadFile getFile4() {
return file4;
}

public void setFile4(IUploadFile value) {
file4 = value;
}

-------------------------------------------------

List affixList = new ArrayList();
System.out.println("file= "+ this.getFile0());
if (this.getFile0()!= null) {
affixList.add(this.getFile0());
}
if (this.getFile1() != null) {
affixList.add(this.getFile1());
}
if (this.getFile2()!= null) {
affixList.add(this.getFile2());
}
if (this.getFile3()!= null) {
affixList.add(this.getFile3());
}
if (this.getFile4()!= null) {
affixList.add(this.getFile4());
}

-------------------------------------------------

List affixPathList = MailUtil.saveTempFile(visit.getUserid(),affixList);

/**
* 将上传的附件保存在临时文件夹
* @param dirName String
* @param affixList List
* @throws Exception
* @return List
*/
public static List saveTempFile(String dirName, List affixList)
throws Exception {
List filePathList = new ArrayList();
try {
String dirPath = makeMailDir(dirName + "//temp");

if (!affixList.isEmpty()) {
Iterator it = affixList.iterator();
while (it.hasNext()) {
IUploadFile uploadFile = (IUploadFile) it.next();
String fileName = uploadFile.getFileName();
File file = new File(dirPath + fileName);
uploadFile.write(file);
filePathList.add(dirPath + fileName);

}
logger.debug("已将附件写进服务器临时文件夹");
}

} catch (Exception ex) {
logger.error("in method saveTempFile", ex);
throw ex;
}
return filePathList;
}

-------------------------------------------------

mail.setAffixList(affixPathList);

dirName, List affixList)
throws Exception {
List filePathList = new ArrayList();
try {
String dirPath = makeMailDir(dirName + "//temp");

if (!affixList.isEmpty()) {
Iterator it = affixList.iterator();
while (it.hasNext()) {
IUploadFile uploadFile = (IUploadFile) it.next();
String fileName = uploadFile.getFileName();
File file = new File(dirPath + fileName);
uploadFile.write(file);
filePathList.add(dirPath + fileName);

}
logger.debug("已将附件写进服务器临时文件夹");
}

} catch (Exception ex) {
logger.error("in method saveTempFile", ex);
throw ex;
}
return filePathList;
}

-------------------------------------------------

mail.setAffixList(affixPathList);

分享到:
评论

相关推荐

    深入浅出Tapestry

    资源名称:深入浅出Tapestry内容简介:本书以循序渐进的方式,从Tapestry框架技术的基本概念入手,讲解Tapestry框架在J2EE Web应用程序中的整体架构实现。使读者在学习如何使用Tapestry框架技术的同时,还能够获得在...

    tapestry教程资料文档合集

    Tapestry5最新中文教程.doc 作者 Renat Zubairov & Igor Drobiazko译者 沙晓兰 发布于 2008年7月2日 下午9时30分 社区 Java 主题 Web框架 ----------------------------------------- Tapestry5.1实例教程.pdf ...

    Tapestry 5 電子書

    最新Tapestry 5 電子書

    tapestry 实例

    tapestry 实例tapestry 实例tapestry 实例tapestry 实例

    tapestry官方中文文档

    Tapestry 4 官方文档中文版本,现在中文资料比较少,和大家共享一下

    tapestry5以上的帮助事例,帮助文档与spring衔接文档

    Tapestry是一个基于控件的框架以致于用它开发Web应用类似开发传统的GUI应用。你用Tapestry开发Web应用时你无需关注以操作为中心的(Operation-centric) Servlet API.引用Tapestry网站上的一句话:"Tapestry用对象...

    Tapestry5.0.16_API文档

    Tapestry5.0.16文档和大家一起学习

    tapestry3开发指南,带tapestry3所有jar包

    tapestry3开发指南,带tapestry3所有jar包

    Tapestry4开发指南

    Tapestry4开发指南

    Tapestry5.1学习全集多本书整合

    是一本由多本Tapestry资料整合而成。包括一些Tapestry的实例。

    深入浅出tapestry

    本书以循序渐进的方式,从Tapestry框架技术的基本概念入手,讲解Tapestry框架在J2EE Web应用程序中的整体架构实现。使读者在学习如何使用Tapestry框架技术的同时,还能够获得在J2EE Web应用程序中应用Tapestry框架的...

    Tapestry5最新中文入门实例教程

    从多方面来讲解 Tapestry应用,比如应用的页面导航(page navigation)、依赖性(dependency)和资源注入(resource injection)、用户输入验证(input validation)和应用状态管理(state management)。...

    tapestry-src-5.1.0.5.zip

    包含: tapestry 的源代码, tapestry集成spring2.0 tapestry快速启动 tapestry upload tapestry hibernate tapestry annotations

    tapestry技术

    tapestry技术 Tapestry是一个开源的基于servlet的应用程序框架,它使用组件对象模型来创建动态的,交互的web应用。一个组件就是任意一个带有jwcid属性的html标记。其中jwc的意思是Java Web Component。Tapestry使得...

    tapestry5.2.6 jar包

    tapestry5.2.6 最新jar包,Tapestry框架是一个位于java servlet容器和Tapestry应用程序之间的层

    Tapestry开发指南

    Tapestry是一个开源的基于servlet的应用程序框架,它使用组件对象模型来创建动态的,交互的web应用。一个组件就是任意一个带有jwcid属性的html标记。其中jwc的意思是Java Web Component。Tapestry使得java代码与html...

    Tapestry

    Tapestry简明教程

    Tapestry通用WEB框架

    Tapestry通用WEB框架支持,切换皮肤,自主分页,

    tapestry源码 api等

    tapestry源码文档以及API,需要更早版本请私信

Global site tag (gtag.js) - Google Analytics