天天看點

Struts 架構 之 檔案上傳下載下傳案例Struts 架構 檔案上傳

    導jar包:

      jar包的具體作用在前面的文章有講。

    

    配置 web.xml

<a></a>

    然後開始開發action 

    上傳action類:FileUpload  src/com.yif.fileupload

    jsp : &lt;input type="file" name="file1"&gt;

    action類中使用  File file1 和 jsp中名字要相同

    file1FileName  file1ContentType 中的file1 需要與jsp中對應

    開發下載下傳檔案 action類: DownAction  src/com.yif.fileupload

    list方法 将上傳檔案的路徑下的檔案 放在list中寫道請求中。

    寫upload.xml    src/com.yif.fileupload

    下載下傳配置詳細:

    配置struts.xml  src/struts.xml

    upload.jsp頁面(前端采用Bootstrap架構)   WebRoot/e/upload.jsp

    list.jsp頁面                WebRoot/e/list.jsp

    實作效果:

    error.jsp  success.jsp略