隨筆-124  評論-49  文章-56  trackbacks-0
          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 閱讀(426) 評論(0)  編輯  收藏 所屬分類: struts2/struts1.3/JSF
          主站蜘蛛池模板: 通化市| 赣榆县| 磴口县| 南丹县| 正蓝旗| 绵竹市| 沿河| 漯河市| 景泰县| 霞浦县| 建始县| 遂平县| 寻乌县| 玉环县| 安溪县| 凌源市| 阿巴嘎旗| 朝阳区| 巴马| 泰顺县| 武清区| 堆龙德庆县| 岑溪市| 桐乡市| 灵寿县| 上栗县| 黄大仙区| 新邵县| 旬邑县| 侯马市| 崇左市| 高陵县| 高阳县| 霍林郭勒市| 元氏县| 综艺| 姜堰市| 厦门市| 安远县| 丰镇市| 承德市|