1 建立页面
<form action="" name="form1" enctype="multipart/form-data" method="post">
2 建ActionForm类
private String title;
private FormFile file;//必须用apache的FormFile类(org.apache.struts.upload.FormFile)
3 建立Action类
UplodaActionForm uaf=(UplodaActionForm)form;
Systyem.out.println("title:"+uaf.getTitle());
FormFile file=uaf.getFile();
if(file!=null)
{
System.out.println("fileName:"+file.getFileName());
FileOutputStream fos=new FileOutputStream("c:\\"+file.getFileName());
fos.write(file.getFileData());
fos.flush();
fos.close();
}
return mapping.findForward("sessucc");
4 配置ActionForm和Action
<controller MaxFileSize="10M"></controller>该属性可以配置上传文件的大小等相关信息
posted on 2009-11-30 08:16
junly 阅读(415)
评论(0) 编辑 收藏 所属分类:
struts2/struts1.3/JSF